You are given an undirected tree (a connected acyclic undirected graph) of $n$ vertices rooted at $1$. Vertices are numbered from $1$ to $n$. The $i_{th}$ node has the value $a_{i}$.
Then there are $q$ queries, each of them contains two integers: $x, k$. For each query, you are required to count how many pairs of ($i,j$) that satisfy the following condition:
-
$a_{i} = x$.
-
$\left| {a_{i}-b_{i}} \right| \leq k$.
-
The $j_{th}$ node is an ancestor of the $i_{th}$ node.