In a tree T with N nodes, each node has a value A[i]. You are given Q queries of the form u v. For each query, we need to find the value of function F.
Function F is defined as the sum of the Bitwise OR and XOR operations on the values of nodes in a simple path between nodes u and v.
To simplify, you need to calculate the sum of OR and XOR of the values of nodes on the path between u and v for each query.
Input Format:
Output Format:
For every query output the value of function F
Constraints:
1≤N≤2×1051≤Q,A[i]≤1051≤u,v≤N
So, for Query 1 , F = 63 + 63 = 126
Similarly for Query 2 , F = 3 + 3 = 6