Problem: We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.
Given an undirected labeled tree consisting of vertices, find a set of segments such that:
- both endpoints of each segment are integers from to , and each integer from to should appear as an endpoint of exactly one segment;
- all segments are non-degenerate;
- for each pair such that , and , the vertices and are connected with an edge if and only if the segments and intersect, but neither segment is fully contained in segment , nor segment is fully contained in segment .
Can you solve this problem too?
Input Format: The first line contains one integer () — the number of vertices in the tree.
Then lines follow, each containing two integers and (, ) denoting the endpoints of the -th edge.
It is guaranteed that the given graph is a tree.
Output Format: Print pairs of integers, the -th pair should contain two integers and () — the endpoints of the -th segment. All integers you print should be unique.
It is guaranteed that the answer always exists.