|
||||||||||
CRB and GraphTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1115 Accepted Submission(s): 433 Problem Description A connected, undirected graph of $N$ vertices and $M$ edges is given to CRB. A pair of vertices ($u$, $v$) ($u$ < $v$) is called critical for edge $e$ if and only if $u$ and $v$ become disconnected by removing $e$. CRB¡¯s task is to find a critical pair for each of $M$ edges. Help him! Input There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case: The first line contains two integers $N$, $M$ denoting the number of vertices and the number of edges. Each of the next $M$ lines contains a pair of integers $a$ and $b$, denoting an undirected edge between $a$ and $b$. 1 ¡Ü $T$ ¡Ü 12 1 ¡Ü $N$, $M$ ¡Ü $10^{5}$ 1 ¡Ü $a$, $b$ ¡Ü $N$ All given graphs are connected. There are neither multiple edges nor self loops, i.e. the graph is simple. Output For each test case, output $M$ lines, $i$-th of them should contain two integers $u$ and $v$, denoting a critical pair ($u$, $v$) for the $i$-th edge in the input. If no critical pair exists, output "0 0" for that edge. If multiple critical pairs exist, output the pair with largest $u$. If still ambiguous, output the pair with smallest $v$. Sample Input
Sample Output
Author KUT£¨DPRK£© Source | ||||||||||
|