#ARC092D. [ARC092F] Two Faced Edges

[ARC092F] Two Faced Edges

Score : 11001100 points

Problem Statement

You are given a directed graph with NN vertices and MM edges. The vertices are numbered 1,2,...,N1, 2, ..., N, and the edges are numbered 1,2,...,M1, 2, ..., M. Edge ii points from Vertex aia_i to Vertex bib_i.

For each edge, determine whether the reversion of that edge would change the number of the strongly connected components in the graph.

Here, the reversion of Edge ii means deleting Edge ii and then adding a new edge that points from Vertex bib_i to Vertex aia_i.

Constraints

  • 2N10002 \leq N \leq 1000
  • 1M200,0001 \leq M \leq 200,000
  • 1ai,biN1 \leq a_i, b_i \leq N
  • aibia_i \neq b_i
  • If iji \neq j, then aiaja_i \neq a_j or bibjb_i \neq b_j.

Input

Input is given from Standard Input in the following format:

NN MM

a1a_1 b1b_1

a2a_2 b2b_2

::

aMa_M bMb_M

Output

Print MM lines. In the ii-th line, if the reversion of Edge ii would change the number of the strongly connected components in the graph, print diff; if it would not, print same.

3 3
1 2
1 3
2 3
same
diff
same

The number of the strongly connected components is 33 without reversion of edges, but it will become 11 if Edge 22 is reversed.

2 2
1 2
2 1
diff
diff

Reversion of an edge may result in multiple edges in the graph.

5 9
3 2
3 1
4 1
4 2
3 5
5 3
3 4
1 2
2 5
same
same
same
same
same
diff
diff
diff
diff