A rooted tree consisting of vertices is given. Each vertex is colored with one of colors. For each vertex , determine the number of distinct colors that appear in the subtree rooted at .
The first line contains a single integer (1 \le n \le 10^6). The following lines describe the vertices of the tree. The -th line contains two integers p_i and c_i, where p_i is the parent of vertex , and c_i is the color of vertex (1 \le c_i \le n). For the root of the tree, p_i = 0.
Print integers — one for each vertex from to . For each vertex, print the number of distinct colors in the subtree rooted at that vertex.

Örnek 1