#abc220f. [abc220_f]Distance Sums 2
[abc220_f]Distance Sums 2
Problem Statement
Given is a tree with vertices. The vertices are numbered , and the -th edge is an undirected edge connecting Vertices and .
For each integer , find .
Here, denotes the minimum number of edges that must be traversed to go from Vertex to Vertex .
Constraints
- The given graph is a tree.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain .
Sample Input 1
3
1 2
2 3
Sample Output 1
3
2
3
We have:
,
,
.
Sample Input 2
2
1 2
Sample Output 2
1
1
Sample Input 3
6
1 6
1 5
1 3
1 4
1 2
Sample Output 3
5
9
9
9
9
9