eolymp
bolt
Try our new interface for solving problems
Problems

Get a tree

Get a tree

The connected undirected graph without loops and multiple edges is given. You are allowed to remove the edges from it. Obtain a tree from the graph. \InputFile The first line contains the number of vertices $n~(1 \le n \le 100)$ and the number of edges $m$ of the graph. The next $m$ pairs of numbers define the edges. It is guaranteed that the graph is connected. \OutputFile Print $n - 1$ pairs of numbers --- the edges that will be included in a tree. The edges can be displayed in any order. \includegraphics{https://static.e-olymp.com/content/e8/e8ab8d33f8ce8ed2a66e9e43a10062f13ffa71b6.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
4 4
1 2
2 3
3 4
4 1
Output example #1
1 2
2 3
3 4