F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

CRB and Graph

Time 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
2 3 2 3 1 2 3 3 3 1 2 2 3 3 1
 

Sample Output
1 2 2 3 0 0 0 0 0 0
 

Author
KUT£¨DPRK£©
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-25 08:06:57, Gzip enabled