atcoder#ABC185F. [ABC185F] Range Xor Query

[ABC185F] Range Xor Query

Score : 600600 points

Problem Statement

We have an integer sequence AA of length NN. You will process QQ queries on this sequence. In the ii-th query, given values TiT_i, XiX_i, and YiY_i, do the following:

  • If Ti=1T_i = 1, replace AXiA_{X_i} with AXiYiA_{X_i} \oplus Y_i.
  • If Ti=2T_i = 2, print $A_{X_i} \oplus A_{X_i + 1} \oplus A_{X_i + 2} \oplus \dots \oplus A_{Y_i}$.

Here, aba \oplus b denotes the bitwise XOR of aa and bb.

What is bitwise XOR?

The bitwise XOR of integers AA and BB, ABA \oplus B, is defined as follows:

  • When ABA \oplus B is written in base two, the digit in the 2k2^k's place (k0k \geq 0) is 11 if either AA or BB, but not both, has 11 in the 2k2^k's place, and 00 otherwise.

For example, 35=63 \oplus 5 = 6. (In base two: 011101=110011 \oplus 101 = 110.)

Constraints

  • 1N3000001 \le N \le 300000
  • 1Q3000001 \le Q \le 300000
  • 0Ai<2300 \le A_i \lt 2^{30}
  • TiT_i is 11 or 22.
  • If Ti=1T_i = 1, then 1XiN1 \le X_i \le N and 0Yi<2300 \le Y_i \lt 2^{30}.
  • If Ti=2T_i = 2, then 1XiYiN1 \le X_i \le Y_i \le N.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN QQ

$A_1 \hspace{7pt} A_2 \hspace{7pt} A_3 \hspace{5pt} \dots \hspace{5pt} A_N$

T1T_1 X1X_1 Y1Y_1

T2T_2 X2X_2 Y2Y_2

T3T_3 X3X_3 Y3Y_3

\hspace{22pt} \vdots

TQT_Q XQX_Q YQY_Q

Output

For each query with Ti=2T_i = 2 in the order received, print the response in its own line.

3 4
1 2 3
2 1 3
2 2 3
1 2 3
2 2 3
0
1
2

In the first query, we print 123=01 \oplus 2 \oplus 3 = 0. In the second query, we print 23=12 \oplus 3 = 1. In the third query, we replace A2A_2 with 23=12 \oplus 3 = 1. In the fourth query, we print 13=21 \oplus 3 = 2.

10 10
0 5 3 4 7 0 0 0 1 0
1 10 7
2 8 9
2 3 6
2 1 6
2 1 10
1 9 4
1 6 1
1 6 3
1 1 7
2 3 5
1
0
5
3
0