#1335
Unrated
Connections
스페셜 저지
시간 제한
3s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Hard times are coming to Byteland. Quantum computing is becoming mainstream and Qubitland is going to occupy Byteland. The main problem is that Byteland does not have enough money for this war, so the King of Byteland Byteman 0x0B had decided to reform its road system to reduce expenses.

Byteland has nn cities that are connected by mm one-way roads and it is possible to get from any city to any other city using these roads. No two roads intersect outside of the cities and no other roads exist. By the way, roads are one-way because every road has a halfway barrier that may be passed in one direction only. These barriers are intended to force enemies to waste their time if they choose the wrong way.

The idea of the upcoming road reform is to abandon some roads so that exactly 2n2n roads remain. Advisers of the King think that it should be enough to keep the ability to get from any city to any other city. (Maybe even less is enough? They do not know for sure.) The problem is how to choose roads to abandon. Everyone in Byteland knows that you are the only one who can solve this problem.

입력

Input consists of several test cases. The first line of the input contains the number of tests cases.

The first line of each test case contains nn and mm — the number of cities and the number of roads correspondingly (n4n \ge 4, m>2nm > 2n). Each of the next mm lines contains two numbers xix_i and yiy_i denoting a road from city xix_i to city yiy_i (1xi,yin1 \le x_i, y_i \le n, xiyix_i \ne y_i). It is guaranteed that it is possible to get from any city to any other city using existing roads only. For each pair (x,y)(x, y) of cities there is at most one road going from city xx to city yy and at most one road going from city yy to city xx. The solution is guaranteed to exist. The sum of mm over all test cases in a single input does not exceed 100000100\,000.

출력

For each test case output m2nm - 2n lines. Each line describes a road that should be abandoned. Print the road in the same format as in the input: the number of the source city and the number of the destination city. The order of roads in the output does not matter, but each road from the input may appear in the output at most once and each road in the output must have been in the input. It still must be possible to get from any city to any other city using the remaining roads.

예제 입력 1

1
4 9
1 2
1 3
2 3
2 4
3 2
3 4
4 1
4 2
4 3

예제 출력 1

1 3
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.