Bus Routes

On a tree with N stops, every ordered pair sends a bus along the unique path; for each stop count how many of the N(N-1) buses halt there, including endpoints.

Medium5TreeMathDFSInterviewNo attempts yetTime limit3sMemory limit1024 MB

Problem

A Czech town called Kocourkov has a public transport system. It has NN bus stops and N1N - 1 two-way roads, and each road joins two different stops. From any stop you reach every other stop by following roads.

Every morning each stop sends out exactly one bus to every other stop, so there are N(N1)N(N - 1) buses in total. A bus halts once at every stop on the route from its origin to its destination.

Every stop needs a timetable that lists all the buses halting there. The buses that begin their route at that stop and the buses that end their route there belong on the timetable too.

You are given a description of the transport system in Kocourkov. For every stop, count the buses that halt there.

Input

The first line contains NN, the number of bus stops. The stops are numbered 1 through NN. Each of the next N1N - 1 lines describes one road of the town and contains the numbers of the two different stops it joins, xx and yy (1x,yN1 \le x, y \le N).

1N1061 \le N \le 10^6.

Output

Print NN lines. Line ii contains a single integer, the number of buses that halt at stop ii.