John isi renoveaza ferma

Time limit: 1s Memory limit: 256MB Input: Output:

Task

John Marston, the classic character from the game Red Dead Redemption, has reunited with Abigail and the two are renovating their farm at Beecher's Hope.

He has NN plantations numbered from 11 to NN, with N1N - 1 roads between them, in the form of a tree rooted at 11. On each plantation he has a number of plants, initially 00 everywhere. Abigail wants to make QQ changes to this tree, and she has 22 kinds of changes:

  • 1 x : Node xx gets a new child, initialized to 00 (first n+1n + 1 is added, then n+2n + 2, n+3n + 3, etc.)
  • 2 x y : For each node ii in the subtree rooted at node xx, the number of plants in node ii is XORed with yy.

Now the two of them, like your usual farmers, are curious for each plantation ii, how many other plantations have the same number of plants as it?

Input

On the first line, the number NN is given, followed by N1N - 1 lines describing the edges of the tree. Then, QQ is given, and the QQ operations with the format described in the statement.

Output

The required answers will be displayed, on a single line, for each node, separated by spaces.

Restrictions and specifications

  • 1N21051 \leq N \leq 2 \cdot 10^5;
  • 1Q21051 \leq Q \leq 2 \cdot 10^5;
  • QN3Q \leq N \cdot 3;
  • 1xthe number of nodes at any moment1 \leq x \leq \text{the number of nodes at any moment};
  • 1y1091 \leq y \leq 10^9;
  • It is guaranteed that initial edges form a tree.

Subtasks

  • For tests worth 1010 points: N1 000N \leq 1\ 000, each edge is of the form (i,i+1)(i, i + 1), there are only operations of type 22
  • For other tests worth another 1010 points: each edge is of the form (i,i+1)(i, i + 1), there are only operations of type 22
  • For other tests worth another 2020 points: N1 000N \leq 1\ 000, there are only operations of type 22
  • For other tests worth another 1010 points: there are only operations of type 22
  • For other tests worth another 5050 points: no other restrictions

Example 1

stdin

5
1 2
1 3
1 4
5 3
4
1 3
2 3 2
2 6 3
1 5

stdout

3 3 1 3 1 0 3

Explanation

After the first operation, the edge (3,6)(3, 6) is added.

After the second operation, the plantations 33, 55, 66 have the number of plants XORed by 22, now having 22 plants.

After the third operation, the plantation 66 has the number of plants XORed by 33, now having 11 plant.

After the fourth operation, the edge (5,7)(5, 7) is added.

The number of plants in each plantation are, in order:

0 0 2 0 2 1 0

which corresponds to the solution in the output (the plantation 11 has 33 other plantations with the same number of plants, the plantation 33 only one with the same number of plants, etc.).

Log in or sign up to be able to send submissions!