#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int M = 200005;
bool edge[N][N];
bool not_necessary[N][N];
vector<int> con[N];
int a[M], b[M];
int vis[N];
int fe[N];
struct graph {
  int n;
  vector<vector<int>> adj;
  graph(int n) : n(n), adj(n) {}
  void add_edge(int src, int dst) { adj[src].push_back(dst); }
  vector<vector<int>> strongly_connected_components() {
    vector<vector<int>> scc;
    vector<int> second, B, I(n);
    function<void(int)> dfs = [&](int u) {
      B.push_back(I[u] = second.size());
      second.push_back(u);
      for (int v : adj[u]) {
        if (!I[v])
          dfs(v);
        else
          while (I[v] < B.back()) B.pop_back();
      }
      if (I[u] == B.back()) {
        scc.push_back({});
        B.pop_back();
        for (; I[u] < second.size(); second.pop_back()) {
          scc.back().push_back(second.back());
          I[second.back()] = n + scc.size();
        }
      }
    };
    for (int u = 0; u < n; ++u)
      if (!I[u]) dfs(u);
    return scc;
  }
};
int main() {
  int n, m;
  scanf("%d", &(n));
  scanf("%d", &(m));
  graph g(n + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &(a[i]));
    scanf("%d", &(b[i]));
    con[a[i]].push_back(b[i]);
    g.add_edge(a[i], b[i]);
  }
  vector<vector<int>> comp = g.strongly_connected_components();
  vector<int> where(n + 1);
  for (int i = 0; i < comp.size(); i++)
    for (auto it : comp[i]) where[it] = i;
  queue<pair<int, int>> q;
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof vis);
    for (int v : con[i]) {
      q.push({v, v});
      vis[v] = 1;
    }
    while (!q.empty()) {
      auto it = q.front();
      q.pop();
      int u = it.first, firstEdge = it.second;
      for (int v : con[u]) {
        if (v == i || vis[v] >= 2) continue;
        if (vis[v] == 1 && firstEdge == fe[v]) continue;
        q.push({v, firstEdge});
        if (vis[v] == 0) fe[v] = firstEdge;
        vis[v]++;
      }
    }
    for (int v : con[i])
      if (vis[v] == 2) {
        not_necessary[i][v] = 1;
      }
  }
  for (int i = 1; i <= m; i++) {
    printf((not_necessary[a[i]][b[i]] ^ (where[a[i]] != where[b[i]]))
               ? "same\n"
               : "diff\n");
  }
}
