Sequence
题号:NC231364
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

There are  types of operations.

Maintain a sequence of  integers , by performing m operations on it:

 for each , replace a_i with . Here, denotes the bitwise and operation.

- print the sum of all the numbers in the interval   module , that is, print .

- 3 - undo the change made by the last operation of type 1 which has not been revoked. It's guaranteed that at least one operation of type not being undone exists when performing it.

3种操作。给定一个长度为  的序列 , 你需要维护 m 次操作:

 对所有的 ,将 a_i 替换成 。这里,   表示位运算的与操作。

 - 输出  区间的数的和模 。换句话说,输出 .

3 - 取消上一次还未取消的类型 的操作。保证在执行这个操作时,至少存在一个未被取消的类型  的操作。


输入描述:


The first line contains 2 integers n and  - the length of the sequence and the number of operations.

The next line contains n integers  separated by spaces, representing the initial sequence.
 
Then m lines follow. The i-th line contains the i-th operation. The format of the operation input is shown above. 

第一行包含两个整数.

第二行包含 n个整数   .

接下来 m 行,每行一个操作,格式同题目描述。

输出描述:

For each operation of type 2, output a line of a single integer, representing the answer.

对于每个询问,输出每行一个整数,表示相应的答案。

示例1

输入

复制
10 3
1 2 3 4 5 6 7 8 9 10
1 1 10
2 1 10
3

输出

复制
6