Given a Tree of n vertices numbered from 1 to n. Each edge is associated with some weight given by array _tree_weight_. There are _q queries_ in the form of a 2-D array, queries, where each element consist of two integers (say, u and v). For each query, compute the sum of **bitwise XOR, the bitwise AND, and the bitwise OR** of the weights of the edges on the path from u->v. Return the answer to each query as an array of integers.↵
↵
**Example-**↵
n = 3<br>↵
n = 3 <br>↵
tree_from = [1,3] <br>↵
tree_to = [2,2] <br>↵
tree_weight = [2,3] <br>↵
q = 2 <br>↵
queries = [[1,3],[2,3]] <br>↵
Edges of the tree in the form (u,v,w) are (1,2,2),(3,2,3)↵
<br>↵
<br>↵
For query 0, u = 1, v = 3; <br>↵
XOR of the weights = 2 ^ 3 = 1 <br>↵
AND of the weights = 2 & 3 = 2 <br>↵
OR of the weights = 2 | 3 = 3 <br>↵
Hence the answer to this query is 1 + 2 + 3 = 6↵
<br>↵
<br>↵
For query 1, u = 2, v = 3; <br>↵
XOR of the weights = 3 <br>↵
AND of the weights = 3 <br>↵
OR of the weights = 3 <br>↵
Hence the answer to this query is 3 + 3 + 3 = 9 <br>↵
Return the array [6,9]. <br>↵
↵
↵
**Example-**↵
n = 3 <br>↵
tree_from = [1,3] <br>↵
tree_to = [2,2] <br>↵
tree_weight = [2,3] <br>↵
q = 2 <br>↵
queries = [[1,3],[2,3]] <br>↵
Edges of the tree in the form (u,v,w) are (1,2,2),(3,2,3)
<br>↵
For query 0, u = 1, v = 3; <br>↵
XOR of the weights = 2 ^ 3 = 1 <br>↵
AND of the weights = 2 & 3 = 2 <br>↵
OR of the weights = 2 | 3 = 3 <br>↵
Hence the answer to this query is 1 + 2 + 3 = 6
<br>↵
For query 1, u = 2, v = 3; <br>↵
XOR of the weights = 3 <br>↵
AND of the weights = 3 <br>↵
OR of the weights = 3 <br>↵
Hence the answer to this query is 3 + 3 + 3 = 9 <br>↵
Return the array [6,9]. <br>↵
↵