#P2137. Gty的妹子树

Gty的妹子树

Description

Maintain a rooted tree with nn nodes initially (the root is 11), with node labels 1n1 \sim n, and each node has a weight wiw_i.

Support the following operations:

  • 0 u x Query the number of values strictly greater than xx in the subtree rooted at uu.
  • 1 u x Set the weight of node uu to xx.
  • 2 u x Add a node whose index is "current number of nodes in the tree + 1", with parent uu and weight xx.

This problem is strictly online.
All input u,xu, x must be XORed with last\text{last} to obtain the actual input.
Here last\text{last} is the answer to the previous query, with initial last=0\text{last} = 0.

Input Format

The first line contains a positive integer nn, the initial number of nodes.

The next n1n-1 lines each contain two integers u,vu, v, representing an undirected edge in the tree.

The next line contains nn integers wiw_i, the initial weight of each node.

The next line contains a positive integer mm, the number of operations.

The next mm lines each contain three integers op,u,x\text{op}, u, x, describing one operation.

Output Format

For each operation with op=0\text{op} = 0, output one line containing an integer, as described above.

2
1 2
10 20
1
0 1 5

2

2
1 2
10 20
1
0 1 10

1

Hint

Constraints
For 100%100\% of the testdata, 1n,m300001 \le n, m \le 30000, 1un1 \le u \le n, 0wi,x<2310 \le w_i, x < 2^{31}.

Translated by ChatGPT 5