시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 1024 MB195545.455%

문제

Grammy has a tree with vertices numbered from $1$ to $n$. For each vertex as the root, she wants to know how many unordered pairs of points $(x, y)$ have their lowest common ancestor $z$ satisfy the inequality $z \leq x \cdot y$. Please count it for her.

입력

The first line contains a single integer $n$ ($1 \leq n \leq 300\,000$), denoting the number of vertices of the tree.

Each of the next $n-1$ lines contains two integers $u_i$ and $v_i$ ($1 \leq u_i, v_i \leq n$), indicating that there is an edge between vertex $u_i$ and vertex $v_i$. It is guaranteed that the given graph is a tree.

출력

Output $n$ lines. The $i$-th line must contain a single integer: the number of pairs satisfying the condition when vertex $i$ is the root.

예제 입력 1

5
1 2
4 2
2 5
3 5

예제 출력 1

15
15
15
15
14