Junyi was playing with a link cut tree last night. He has made LCA queries to his link cut tree. Each time, the link cut tree responded with the integer representing the lowest common ancestor. He cut one too many edges and now he can't restore his tree. However, he will be satisfied with any tree that will give him the same results when asked the LCA queries again. Your task is to help him restore his tree. You will be given the queries, and the result of those queries.
Input Specification
On the first line, two integers, and where is the number of nodes.
On the next lines, three integers and , which indicates that the LCA of and is . .
Output Specification
integers, indicating that the parent of is . (e.g. if the first integer is , then the parent of is , if the second integer is , then the parent of is ). Node is always the root, and has special value as the parent. In other words, .
Sample Input
4 3
1 2 1
2 3 2
3 4 3
Sample Output
0 1 2 3
Comments