#include <iostream>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)

int N, M;
int A[1 << 18], B[1 << 18];
int Answer[1 << 18];

// 強連結成分分解
vector<int> X[1009], Y[1009], I;
bool used[1009];
int col[1009], group[1009], cnts;

void dfs1(int pos) {
	used[pos] = true;
	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i]] == true) continue;
		dfs1(X[pos][i]);
	}
	I.push_back(pos);
}

void dfs2(int pos) {
	col[pos] = cnts; group[cnts]++;
	for (int i = 0; i < Y[pos].size(); i++) {
		if (col[Y[pos][i]] >= 1) continue;
		dfs2(Y[pos][i]);
	}
}

// DAG における計算
vector<pair<int, int>> Z[1009];
int dp[1009][1009];

// サイクルの列挙
vector<pair<int, int>> P[1009], Q[1009];
int Score1[1 << 18], Score2[1 << 18];

int dfs5(int pos) {
	used[pos] = true; int r = 1;
	for (int i = 0; i < P[pos].size(); i++) {
		if (used[P[pos][i].first] == true) continue;
		r += dfs5(P[pos][i].first);
	}
	return r;
}

int dfs6(int pos) {
	used[pos] = true; int r = 1;
	for (int i = 0; i < Q[pos].size(); i++) {
		if (used[Q[pos][i].first] == true) continue;
		r += dfs6(Q[pos][i].first);
	}
	return r;
}

// 最後の計算
vector<int> J[1009], J2[1009], K;
int colo[1009], cntv;

void dfs3(int pos) {
	used[pos] = true;
	for (int i : J[pos]) {
		if (used[i] == true) continue;
		dfs3(i);
	}
	K.push_back(pos);
}

void dfs4(int pos) {
	colo[pos] = cntv;
	for (int i : J2[pos]) {
		if (colo[i] >= 1) continue;
		dfs4(i);
	}
}

bool calc(int pos) {
	for (int i = 1; i <= N; i++) J[i].clear();
	for (int i = 1; i <= N; i++) J2[i].clear();
	for (int i = 1; i <= N; i++) used[i] = false;
	for (int i = 1; i <= N; i++) colo[i] = 0;
	cntv = 0;

	for (int i = 1; i <= M; i++) {
		if (i == pos) continue;
		J[A[i]].push_back(B[i]);
		J2[B[i]].push_back(A[i]);
	}
	K.clear();

	for (int i = 1; i <= N; i++) {
		if (used[i] == true) continue;
		dfs3(i);
	}
	
	for (int i = K.size() - 1; i >= 0; i--) {
		if (colo[K[i]] >= 1) continue;
		cntv++; dfs4(K[i]);
	}

	if (cnts == cntv) return false;
	return true;
}

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; i++) {
		scanf("%d%d", &A[i], &B[i]);
		X[A[i]].push_back(B[i]);
		Y[B[i]].push_back(A[i]);
	}

	// ステップ 1: 強連結成分ごとに分ける
	for (int i = 1; i <= N; i++) {
		if (used[i] == true) continue;
		dfs1(i);
	}
	for (int i = I.size() - 1; i >= 0; i--) {
		if (col[I[i]] >= 1) continue;
		cnts++; dfs2(I[i]);
	}

	// ステップ 2: DAG のグラフを処理する
	for (int i = 1; i <= M; i++) {
		if (col[A[i]] == col[B[i]]) continue;
		Z[col[A[i]]].push_back(make_pair(col[B[i]], i));
	}
	vector<pair<int, int>> FF;
	for (int i = 1; i <= cnts; i++) {
		for (int j = 0; j < Z[i].size(); j++) FF.push_back(make_pair(i, Z[i][j].first));
	}
	for (int i = 1; i <= cnts; i++) {
		dp[i][i] = 1;
		for (pair<int, int> j : FF) dp[i][j.second] += dp[i][j.first];
	}
	for (int i = 1; i <= M; i++) {
		if (col[A[i]] == col[B[i]]) continue;
		if (dp[col[A[i]]][col[B[i]]] != 1) Answer[i] = 2;
		else Answer[i] = 1;
	}

	// ステップ 3: 候補辺の列挙
	for (int i = 1; i <= M; i++) {
		if (col[A[i]] != col[B[i]]) continue;
		P[A[i]].push_back(make_pair(B[i], i));
		Q[B[i]].push_back(make_pair(A[i], i));
		Answer[i] = 1;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) used[j] = false;
		used[i] = true;
		for (int j = 0; j < P[i].size(); j++) {
			if (used[P[i][j].first] == true) continue;
			int V1 = dfs5(P[i][j].first);
			Score1[P[i][j].second] = V1;
		}
		for (int j = 1; j <= N; j++) used[j] = false;
		used[i] = true;
		for (int j = 0; j < Q[i].size(); j++) {
			if (used[Q[i][j].first] == true) continue;
			int V2 = dfs6(Q[i][j].first);
			Score2[Q[i][j].second] = V2;
		}
	}
	for (int i = 1; i <= M; i++) {
		if (col[A[i]] != col[B[i]]) continue;
		if (group[col[A[i]]] <= Score1[i] + Score2[i]) Answer[i] = 0;
	}

	// ステップ 4: 最後の計算
	for (int i = 1; i <= M; i++) {
		if (Answer[i] >= 1) continue;
		bool flag = calc(i);
		if (flag == false) Answer[i] = 1;
		else Answer[i] = 2;
	}

	// 出力
	for (int i = 1; i <= M; i++) {
		if (Answer[i] == 1) printf("same\n");
		if (Answer[i] == 2) printf("diff\n");
	}
	return 0;
}

Measured memory_bytes: 19828