atcoder#ARC092D. [ARC092F] Two Faced Edges
[ARC092F] Two Faced Edges
Score : points
Problem Statement
You are given a directed graph with vertices and edges. The vertices are numbered , and the edges are numbered . Edge points from Vertex to Vertex .
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 means deleting Edge and then adding a new edge that points from Vertex to Vertex .
Constraints
- If , then or .
Input
Input is given from Standard Input in the following format:
Output
Print lines. In the -th line, if the reversion of Edge 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 without reversion of edges, but it will become if Edge 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