#abc261e. E - Many Operations

E - Many Operations

Score : 500500 points

问题陈述

我们有一个变量 XXNN 种改变 XX 值的操作。操作 ii 表示为整数对 (Ti,Ai)(T_i,A_i),操作如下:

  • 如果 Ti=1T_i=1,则将 XX 的值替换为 X and AiX\ {\rm and}\ A_i
  • 如果 Ti=2T_i=2,则将 XX 的值替换为 X or AiX\ {\rm or}\ A_i
  • 如果 Ti=3T_i=3,则将 XX 的值替换为 X xor AiX\ {\rm xor}\ A_i

CC 的值初始化 XX 并按顺序执行以下程序:

  • 执行操作 11,然后打印 XX 的结果值。
  • 接下来,按顺序执行操作 1,21, 2,然后打印 XX 的值。
  • 接下来,按顺序执行操作 1,2,31, 2, 3,然后打印 XX 的值。
  • \vdots
  • 接下来,按顺序执行操作 1,2,,N1, 2, \ldots, N,然后打印 XX 的值。

and,or,xor{\rm and}, {\rm or}, {\rm xor} 是什么?

非负整数 AABBand,or,xor{\rm and}, {\rm or}, {\rm xor} 定义如下:

  • A and BA\ {\rm and}\ B 用二进制表示时,2k2^k 位(k0k \geq 0)上的数字如果 AABB 该位上的数字都是 11,则为 11,否则为 00
  • A or BA\ {\rm or}\ B 用二进制表示时,2k2^k 位(k0k \geq 0)上的数字如果 AABB 该位上至少有一个数字是 11,则为 11,否则为 00
  • A xor BA\ {\rm xor}\ B 用二进制表示时,2k2^k 位(k0k \geq 0)上的数字如果 AABB 该位上恰好有一个数字是 11,则为 11,否则为 00

例如,3 and 5=13\ {\rm and}\ 5 = 13 or 5=73\ {\rm or}\ 5 = 73 xor 5=63\ {\rm xor}\ 5 = 6

约束条件

  • 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}
  • 输入中的所有值都是整数。

输入

输入从标准输入按照以下格式给出:

NN CC

T1T_1 A1A_1

T2T_2 A2A_2

\vdots

TNT_N ANA_N

输出

按照问题陈述中的指定打印 NN 行。

示例输入 1

3 10
3 3
2 5
1 12

示例输出 1

9
15
12

变量 XX 的初始值为 1010

  • 操作 11XX 改为 99
  • 接下来,操作 11XX 改为 1010,然后操作 22 将其改为 1515
  • 接下来,操作 11XX 改为 1212,然后操作 22 将其改为 1313,接着操作 33 将其改为 1212

示例输入 2

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

示例输出 2

0
2
1
0
5
3
3
11
2

以上为通义千问 qwen-max 翻译,仅供参考。

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 and,or,xor{\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.

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

update @ 2024/3/10 11:04:30