|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|3 초||1024 MB||6||5||5||83.333%|
In the Czech city called Kocourkov they have a spectacular public transportation system. It consists of N bus stops and N − 1 bidirectional roads, each road connecting two bus stops. It is possible to get from each bus stop to every other using a sequence of roads.
Every morning, for each pair of distinct bus stops a and b there is exactly one bus that starts at aand goes to b (along the only direct path). That is, there are a total of N(N − 1) buses. Each bus stops at all bus stops it visits along the way.
At every bus stop there must be a timetable listing all the buses that stop there (including buses that start or end their journey there). You are now wondering how many buses are listed on each timetable.
You are given the description of the traffic system in Kocourkov. For every bus stop in the city calculate the number of buses that stop on that particular stop.
First line contains an integer N, the number of bus stops in the city (stops are numbered from 1 to N). The following N − 1 lines describe the roads in the city. Each line contains two different integers 1 ≤ x, y ≤ N meaning that there is a road connecting bus stops x and y.
It holds 1 ≤ N ≤ 106
The output consists of N lines. The i-th line should contain a signle integer, the number of buses that stop on the i-th bus stop.
6 1 2 2 3 3 4 4 5 5 6
10 18 22 22 18 10
5 4 5 2 1 3 2 2 5
8 18 8 8 14