You are given a tree that contains N nodes, where every node i is colored with some color Ci.
The distance of a node V from a node U is defined as the number of edges along the simple path from the node U to the node V. Your task is to answer M queries of the following type:
Input format
Output format
For each query, print the distance of most distant node of color C from the node K.
The answer for each query should come in a new line.
Input Constraints
1≤N,M≤5×105
1≤Ci≤5×105
1≤U,V≤N
1≤K≤N
1≤C≤5×105