#ABC261E. [ABC261E] Many Operations

[ABC261E] Many Operations

Score : 500500 points

Problem Statement

We have a variable XX and NN kinds of operations that change the value of XX. Operation ii is represented as a pair of integers (Ti,Ai)(T_i,A_i), and is the following operation:

  • if Ti=1T_i=1, it replaces the value of XX with X and AiX\ {\rm and}\ A_i;
  • if Ti=2T_i=2, it replaces the value of XX with X or AiX\ {\rm or}\ A_i;
  • if Ti=3T_i=3, it replaces the value of XX with X xor AiX\ {\rm xor}\ A_i.

Initialize XX with the value of CC and execute the following procedures in order:

  • Perform Operation 11, and then print the resulting value of XX.
  • Next, perform Operation 1,21, 2 in this order, and then print the value of XX.
  • Next, perform Operation 1,2,31, 2, 3 in this order, and then print the value of XX.
  • \vdots
  • Next, perform Operation 1,2,,N1, 2, \ldots, N in this order, and then print the value of XX.
What are ${\rm and}, {\rm or}, {\rm xor}$?

The and,or,xor{\rm and}, {\rm or}, {\rm xor} of non-negative integers AA and BB are defined as follows:

  • When A and BA\ {\rm and}\ B is written in base two, the digit in the 2k2^k's place (k0k \geq 0) is 11 if both of the digits in that place of AA and BB are 11, and 00 otherwise.
  • When A or BA\ {\rm or}\ B is written in base two, the digit in the 2k2^k's place (k0k \geq 0) is 11 if at least one of the digits in that place of AA and BB is 11, and 00 otherwise.
  • When A xor BA\ {\rm xor}\ B is written in base two, the digit in the 2k2^k's place (k0k \geq 0) is 11 if exactly one of the digits in that place of AA and BB is 11, and 00 otherwise.

For example, 3 and 5=13\ {\rm and}\ 5 = 1, 3 or 5=73\ {\rm or}\ 5 = 7, and 3 xor 5=63\ {\rm xor}\ 5 = 6.

Constraints

  • 1N2×1051 \leq N \leq 2\times 10^5
  • 1Ti31\leq T_i \leq 3
  • 0Ai<2300\leq A_i \lt 2^{30}
  • 0C<2300\leq C \lt 2^{30}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN CC

T1T_1 A1A_1

T2T_2 A2A_2

\vdots

TNT_N ANA_N

Output

Print NN lines, as specified in the Problem Statement.

3 10
3 3
2 5
1 12
9
15
12

The initial value of XX is 1010.

  • Operation 11 changes XX to 99.
  • Next, Operation 11 changes XX to 1010, and then Operation 22 changes it to 1515.
  • Next, Operation 11 changes XX to 1212, and then Operation 22 changes it to 1313, and then Operation 33 changes it to 1212.
9 12
1 1
2 2
3 3
1 4
2 5
3 6
1 7
2 8
3 9
0
2
1
0
5
3
3
11
2