The hanging tree contains n\:(1 \le n \le 10^6) vertices. Each vertex is colored in one of colors. For each vertex find the number of different colors, occurring in the subtree with root .
The first line contains the number . The next lines describe the vertices. The description of the vertex has the form p_i\:c_i, where p_i is the parent number of the vertex , and c_i is the color of the vertex i\:(1 \le c_i \le n). For the root of the tree p_i = 0.
Print numbers, denoting the number of different colors in the subtrees rooted at the vertices 1, 2, ..., n.

Example 1