Tree Distances I#11430

Tree Distances I

3 seconds
1,024 megabytes
Medium

A tree consisting of vertices is given.

For each vertex, determine the maximum distance to any other vertex.

Input

The first line contains an integer n~(1 \le n \le 2 \cdot 10^5) — the number of vertices in the tree. The vertices are numbered from to .

The next n - 1 lines describe the edges: each line contains two integers and b~(1 \le a, b \le n), indicating that there is an edge between vertices and .

Output

Print integers. For each vertex from to , print the maximum distance to any other vertex in the tree.

Examples

Example 1

Loading
Loading