#d1105. Dis
Dis
Dis
Problem Description
You are given a tree of vertices, each with its own vertex weight. Answer multiple queries: for each query, output the XOR sum of the vertex weights on the set of vertices lying on the simple path between two given vertices.
Input Format
The first line contains two integers and , where is the number of vertices and is the number of queries.
The second line contains integers , the vertex weights.
The next lines each contain two integers , indicating an edge between vertices and .
The following lines each contain two integers , representing a query: the XOR sum of the vertex weights on the simple path from to .
Output Format
Output lines, one integer per query, in order.
Sample Input
7 3
0 1 2 3 4 5 6
1 2
1 3
2 4
2 5
3 6
3 7
4 6
4 7
5 6
Sample Output
5
6
2
Constraints
, .