Path (path)

Description


Given a tree of (n) nodes, the node number is (1 sim n) (the root node number is (1)). For each leaf node, output the path from the root to the leaf.
Note: The output will be output according to the lexicographic order of the path from smallest to largest.

Format


Input

The first line: the number of (1) (n) indicates the number of nodes in the tree.
The following (n-1) lines: the number of (2) in each line (x y), indicating that the node (x) is the parent node of the node (y).

Output

The number of output rows is equal to the number of leaf nodes, and each row corresponds to the path from the root to the leaf node. The number in the path is the number of the passing node. According to the lexicographic order of the path, output from small to large.

Sample


Input

5
1 2
1 3
2 4
4 5

Output

1 2 4 5
1 3

Sample Explanation

And (5) are leaf nodes, and the corresponding paths are (1 3) and (1 2 4 5) respectively. The latter has a smaller dictionary order, so the output result is:

1 2 4 5
1 3

Sample Code


Code is not available!
原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13812559.html