Classical Graph Theory Problem

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

문제

Let G=(V,E)G = (V, E) be a connected undirected graph.

A set of vertices SS is called a dominating set if every vertex vVv \in V either belongs to SS, or has a neighbor in SS.

A vertex vv is called a leaf if it has exactly one neighbor.

Graph GG satisfies the following property: every vertex has at most two neighboring leaves.

Find a set SVS \subset V such that:

  • SS is a dominating set in GG;
  • VSV \setminus S is a dominating set in GG;
  • S=V2|S| = \lfloor \frac{|V|}{2} \rfloor.

It is guaranteed that such a set always exists.

입력

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains two integers nn and mm, denoting the number of vertices and the number of edges in GG (2n21052 \le n \le 2 \cdot 10^5; 1m51051 \le m \le 5 \cdot 10^5).

Each of the next mm lines contains two integers x_ix\_i and y_iy\_i, denoting the endpoints of the ii-th edge (1x_i,y_in1 \le x\_i, y\_i \le n; x_iy_ix\_i \ne y\_i). The graph does not contain loops or multiple edges. Every vertex has at most two neighboring leaves.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5, and the sum of mm over all test cases does not exceed 51055 \cdot 10^5.

출력

Print n2\lfloor \frac{n}{2} \rfloor distinct integers s_1,s_2,,s_n/2s\_1, s\_2, \ldots, s\_{\lfloor n/2 \rfloor}, denoting the vertices belonging to SS in any order (1s_in1 \le s\_i \le n).

If there are multiple solutions, print any of them.