#abc308g. [abc308_g]Minimum Xor Pair Query

[abc308_g]Minimum Xor Pair Query

Problem Statement

There is a blackboard on which you can write integers. Initially, no integer is written on the blackboard. Given QQ queries, process them in order.

The query is of one of the following three kinds:

  • 1 x : write an xx on the blackboard.

  • 2 x : erase an xx from the blackboard. At the point this query is given, it is guaranteed that at least one xx is written on the blackboard.

  • 3 : print the minimum possible bitwise XOR of two of the integers written on the blackboard. At the point this query is processed, it is guaranteed that at least two integers are written on the blackboard.

What is bitwise XOR? The bitwise XOR of non-negative integers AA and BB, AoplusBA \\oplus B, is defined as follows.

  • When AoplusBA \\oplus B is written in binary, the 2k2^ks place (kgeq0k \\geq 0) is 11 if exactly one of the 2k2^ks places of AA and BB is 11, and 00 otherwise.

For instance, 3oplus5=63 \\oplus 5 = 6 (in binary: 011oplus101=110011 \\oplus 101 = 110).

Constraints

  • 1leqQleq3times1051\\leq Q \\leq 3\\times 10^5
  • 0leqx<2300\\leq x < 2 ^{30}
  • When a query 22 is given, at least one xx is written on the blackboard.
  • When a query 33 is given, at least two integers are written on the blackboard.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

QQ mathrmquery1\\mathrm{query}_1 mathrmquery2\\mathrm{query}_2 vdots\\vdots mathrmqueryQ\\mathrm{query}_Q

In the ii-th query, mathrmqueryi\\mathrm{query}_i, the kind of query, cic_i (one of 11, 22, or 33), is first given. If ci=1c_i = 1 or ci=2c_i = 2, an integer xx is additionally given.

In other words, each query is in one of the following three formats.

11 xx 22 xx 33

Output

Print qq lines, where qq is the number of queries such that ci=3c_i=3.

The jj-th (1leqjleqq)(1\\leq j\\leq q) line should contain the answer to the jj-th such query.


Sample Input 1

9
1 2
1 10
3
1 3
3
2 2
3
1 10
3

Sample Output 1

8
1
9
0

After processing the 11-st query, a 22 is written on the blackboard.

After processing the 22-nd query, a 22 and a 1010 are written on the blackboard.

When processing the 33-rd query, the minimum possible bitwise XOR of two of the integers written on the backboard is 2oplus10=82\\oplus 10=8.

After processing the 44-th query, a 22, a 33, and a 1010 are written on the blackboard.

When processing the 55-th query, the minimum possible bitwise XOR of two of the integers written on the backboard is 2oplus3=12\\oplus 3=1.

After processing the 66-th query, a 33 and a 1010 are written on the blackboard.

When processing the 77-th query, the minimum possible bitwise XOR of two of the integers written on the backboard is 3oplus10=93\\oplus 10=9.

After processing the 88-th query, a 33 and two 1010s are written on the blackboard.

When processing the 99-th query, the minimum possible bitwise XOR of two of the integers written on the backboard is 10oplus10=010\\oplus 10=0.