Classical Graph Theory Problem
시간 제한4초메모리 제한1024 MB
연결 그래프의 정점을 같은 크기의 두 집합 S와 V∖S로 나눠 두 집합 모두 전체 그래프를 지배하도록 만든다.
문제
Let be a connected undirected graph.
A set of vertices is called a dominating set if every vertex either belongs to , or has a neighbor in .
A vertex is called a leaf if it has exactly one neighbor.
Graph satisfies the following property: every vertex has at most two neighboring leaves.
Find a set such that:
- is a dominating set in ;
- is a dominating set in ;
- .
It is guaranteed that such a set always exists.
입력
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and , denoting the number of vertices and the number of edges in (; ).
Each of the next lines contains two integers and , denoting the endpoints of the -th edge (; ). The graph does not contain loops or multiple edges. Every vertex has at most two neighboring leaves.
It is guaranteed that the sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
출력
Print distinct integers , denoting the vertices belonging to in any order ().
If there are multiple solutions, print any of them.