Degree of Spanning Tree

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Given an undirected connected graph with nn vertices and mm edges, your task is to find a spanning tree of the graph such that for every vertex in the spanning tree its degree is not larger than n2\frac{n}{2}.

Recall that the degree of a vertex is the number of edges it is connected to.

입력

There are multiple test cases. The first line of the input contains an integer TT indicating the number of test cases. For each test case:

The first line contains two integers nn and mm (2n1052 \le n \le 10^5, n1m2×105n-1 \le m \le 2 \times 10^5) indicating the number of vertices and edges in the graph.

For the following mm lines, the ii-th line contains two integers u_iu\_i and v_iv\_i (1u_i,v_in1 \le u\_i, v\_i \le n) indicating that there is an edge connecting vertex u_iu\_i and v_iv\_i. Please note that there might be self loops or multiple edges.

It's guaranteed that the given graph is connected. It's also guaranteed that the sum of nn of all test cases will not exceed 5×1055 \times 10^5, also the sum of mm of all test cases will not exceed 10610^6.

출력

For each test case, if such spanning tree exists first output "Yes" (without quotes) in one line, then for the following (n1)(n-1) lines print two integers p_ip\_i and q_iq\_i on the ii-th line separated by one space, indicating that there is an edge connecting vertex p_ip\_i and q_iq\_i in the spanning tree. If no valid spanning tree exists just output "No" (without quotes) in one line.

힌트

For the first sample test case, the maximum degree among all vertices in the spanning tree is 3 (both vertex 1 and vertex 4 has a degree of 3). As 3623 \le \frac{6}{2} this is a valid answer.

For the second sample test case, it's obvious that any spanning tree will have a vertex with degree of 2, as 2>322 > \frac{3}{2} no valid answer exists.