#C10827. Circular Route Transformation

    ID: 40075 Type: Default 1000ms 256MiB

Circular Route Transformation

Circular Route Transformation

You are given an undirected road network of n intersections and m roads. Although the input lists several roads, your task is to ignore the original connectivity and instead form a circular route by linking the intersections sequentially. In other words, you need to output a cycle that includes every intersection exactly once and returns to the starting point.

Input Format: The first line consists of two integers n and m, where n is the number of intersections and m is the number of roads. Each of the next m lines contains two integers u and v representing a road connecting intersections u and v. Even though extra roads are provided, you must ignore them when forming the circular route.

Output Format: Output n lines. Each line should contain two integers representing a road in the circular route. The route should connect intersection 1 to 2, 2 to 3, ..., (n-1) to n, and finally n to 1.

Note: The answer should form a closed loop (cycle) that covers all intersections exactly once. All formulas, if needed, must follow the LaTeX format.

inputFormat

The input begins with two integers n and m (1 ≤ n, m ≤ 105), denoting the number of intersections and roads, respectively. This is followed by m lines, each containing two integers u and v, representing a road between intersections u and v.

outputFormat

Output exactly n lines, each containing a pair of integers. Line i (for 1 ≤ i < n) should output the road from intersection i to i+1, and the last line should output the road from intersection n to intersection 1, forming a complete circular route.

## sample
4 4
1 2
2 3
3 4
4 1
1 2

2 3 3 4 4 1

</p>