Smaller LCA

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

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

입력

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

Each of the next n1n-1 lines contains two integers u_iu\_i and v_iv\_i (1u_i,v_in1 \leq u\_i, v\_i \leq n), indicating that there is an edge between vertex u_iu\_i and vertex v_iv\_i. It is guaranteed that the given graph is a tree.

출력

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