Problem 5.  TREE

 

Vertex enumeration of a tree is any sequence whose elements are vertices of that tree. If any two consecutive elements in the sequence are vertices whose graph distance is not greater than d this vertex enumeration is called d-enumeration. For any tree there is a 3-enumeration.  Write a program ZAD5.EXE which finds a 3-enumeration for a given tree.

 

INPUT: In the first line of input text file ZAD5.DAT is the number n (1 ≤ n ≤ 30000), the number of vertices in the tree. Vertices are denoted by numbers from 1 to n. In the next n-1 lines there are two integers which determine one edges of the tree.

 

OUTPUT: In every of n lines of output text file ZAD5.RES there is an integer which is element of the 3-enumeration of the given tree in the same sequence as in enumeration.

 

EXAPMLE:

                                 1           4          6          7         2           5           3

 

 

                                                                        8

 

ZAD5.DAT                                         ZAD5.RES

8                       3

1 4                     2

4 6                     6

6 7                     1

3 5                     4

7 2                     8

2 5                     7

8 7                     5