Imagine a network of N points connected by N−1 lines, forming a tree-like structure. Every point has a number assigned to it, given as an array Arr of size N. Now, you need to answer Q queries. In each query, you're asked to do the following:
Note: A simple path is a path in a tree that does not have repeating points.
Input Format:
Output Format:
For each test case, answer all the Q queries. For each query, print in a new line the maximum Bitwise XOR result of all the numbers on points that lie on the simple path between points A and B (inclusive) for each query that you can get after choosing a number α, which lies between 0 & X (inclusive), and each points value has been temporarily modified to Bitwise XOR result of the initial value of that point and α.
Constraints:
1≤T≤1053≤N≤1050≤Arr[i]≤109 ∀ i∈[1,N]1≤U,V≤N1≤Q≤1050≤X≤1091≤A,B≤NThe sum of all values of N over all test cases doesn't exceed 106The sum of all values of Q over all test cases doesn't exceed 106
The first line denotes T = 1.
For test case 1:
We are given:
Now,