#abc261e. [abc261_e]Many Operations

[abc261_e]Many Operations

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 XrmandAiX\\ {\\rm and}\\ A_i;
  • if Ti=2T_i=2, it replaces the value of XX with XrmorAiX\\ {\\rm or}\\ A_i;
  • if Ti=3T_i=3, it replaces the value of XX with XrmxorAiX\\ {\\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\\vdots
  • Next, perform Operation 1,2,ldots,N1, 2, \\ldots, N in this order, and then print the value of XX.

What are rmand,rmor,rmxor{\\rm and}, {\\rm or}, {\\rm xor}?

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

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

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

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2\\times 10^5
  • 1leqTileq31\\leq T_i \\leq 3
  • 0leqAilt2300\\leq A_i \\lt 2^{30}
  • 0leqClt2300\\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\\vdots TNT_N ANA_N

Output

Print NN lines, as specified in the Problem Statement.


Sample Input 1

3 10
3 3
2 5
1 12

Sample Output 1

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.

Sample Input 2

9 12
1 1
2 2
3 3
1 4
2 5
3 6
1 7
2 8
3 9

Sample Output 2

0
2
1
0
5
3
3
11
2