You are given a tree with $$$n$$$ nodes numbered from $$$1$$$ to $$$n$$$. Each node $$$i$$$ has an integer value $$$a_i$$$. The tree is rooted at node $$$1$$$.
You will receive $$$q$$$ queries. In the $$$i$$$-th query, you are given two integers $$$u_{\text{input}}$$$ and $$$v_{\text{input}}$$$. Your task is to determine the number of nodes $$$x$$$ satisfying:
The queries are encrypted. The actual nodes for the $$$i$$$-th query are computed as:
$$$u = u_{\text{input}} \oplus \text{last}, \quad v = v_{\text{input}} \oplus \text{last},$$$
where $$$\text{last}$$$ is the answer to the previous query (assume $$$\text{last} = 0$$$ for the first query).
The first line contains an integer $$$n$$$ — the number of nodes.
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ — the values of the nodes.
Each of the next $$$n-1$$$ lines contains two integers $$$x, y$$$, denoting an edge of the tree.
The next line contains an integer $$$q$$$ — the number of queries.
Each of the following $$$q$$$ lines contains two integers $$$u_{\text{input}}, v_{\text{input}}$$$.
Constraints
Print $$$q$$$ integers, each on its own line — the answer to each query.
5 2 3 6 5 7 1 2 1 3 3 4 3 5 3 2 4 4 5 3 3
1 2 0
| Name |
|---|


