You are given an undirected tree with N nodes rooted at node 1. Every node has a value A[i] assigned to it. You are required to answer Q queries of the following type:
Find the required answer for Q queries.
Note:
Input format
Output format
For each test case, print Q space-separated integers denoting the longest length common prefix for Q queries. Print the output for each test case in a new line.
Constraints
1≤T≤51≤N,Q≤1051≤A[i],V≤1091≤X≤N