You are very curious to know about the frequency of stocks. The stocks are represented as nodes of a tree with prices of the stocks as their value.
You are given a tree with nodes (each node represents a stock) numbered from to (rooted at ). Each stock has a value that is denoted by . You are given queries of the form . For each of the queries, you are required to determine the number of different stock prices or values that are available in the subtree of for which frequency is between and (both inclusive).
Input format
Output format
Print lines containing the answer to each query.
Constraints
0 (1 has frequency 3 and 2 has frequency 1 in the subtree of 2)
2 (1 has freq 3 and 2 has freq 3)
1 (1 has freq 2 and 2 has freq 0)