Claris loves painting very much, so he painted a tree with beautiful colors.
The tree is a rooted tree with $n$ nodes which are conveniently labeled by $1,2,...,n$. Its root is the $1$-st node, and the $i$-th node is painted with color $c_i$. If $c_i=c_j$, then we think these two nodes have the same color.
We define $depth_i$ as the distance between the $i$-th node and the root, and simply, the distance between two adjacent nodes is always $1$.
Standing in front of this beautiful tree, Claris comes up with $m$ questions.
In each question, there are two integers $x$ and $d$, which means that Claris wants to know the number of different kinds of colors occur in $S$, where $S=\left\{v|v\ in\ x's\ subtree\ and\ depth_v\leq depth_x+d\right\}$.