There is a bidirectional unweighted connected graph with nodes, numbered from to , each with a value .
There are exactly edges. The edge connects and . There is at most one edge between any pair of nodes. No edge connects a node with itself.
questions are asked in the form: "On the path from to , including these and themselves, how many nodes have a value of at least ?".
Constraints
All numbers in the input are positive integers.
Input Specifications
All numbers on the same line of input are separated by spaces.
The first line of input contains numbers: and .
The second line of input contains numbers, the number is .
The next lines each contain numbers: and .
The next lines contain numbers: , , and . All of these numbers are encrypted. To decrypt them, take the bitwise XOR with the previous answer. The first of these queries is not encrypted.
Output Specification
lines each containing one number, the line representing the answer to the question.
Sample Input 1
5 2
10 20 30 40 50
1 2
1 3
2 4
2 5
3 4 20
7 6 29
Sample Output 1
3
2
Explanation for Sample 1
The first query is not encrypted.
The path from to is . Out of these trees, of them have a height of at least .
The second query is encrypted. By taking the bitwise XOR of the previous answer, which is in this case , we get
- .
This means the decrypted input is 4 5 30
.
The path from to is . Out of these trees, of them have a height of at least .
Sample Input 1 Without Encryption
This sample does not have the XOR involved. This is just for convenience of viewing and is not representative of the test data.
5 2
10 20 30 40 50
1 2
1 3
2 4
2 5
3 4 20
4 5 30
Comments