1890: And RMQ

内存限制:512 MB 时间限制:3 S
题面:传统 评测方式:文本比较 上传者:
提交:11 通过:3

题目描述

https://codeforces.com/gym/103107/problem/A


You are given a sequence consisting of NN integers {ai}. There will be mm different events.

  • AND l r v – for all elements ai (l≤i≤r), change aiai to ai & v, where & means bitwise AND
  • UPD x v – change ax to v
  • QUE l r – ask for the maximum value of aiai where l≤i≤r

Please write a program to support these events efficiently.

Input

The first line contains two integers N,M (1≤N,M≤400000) denoting the length of sequence and the number of events.

The second line contains NN integers a1,a2,⋯,an (1≤ai≤230−1) denoting the initial elements of the sequence.

For the next M lines, each line describes an event. It is guaranteed that 1≤l,r,x≤nand 1≤v≤230−1.

Output

For each QUEQUE event, print a single line containing an integer, denoting the answer.

It is guaranteed that there is at least one QUEQUE event.

Example
input
Copy
5 11
6 3 5 2 3
AND 2 4 10
UPD 1 8
AND 3 4 7
UPD 1 6
QUE 1 4
AND 3 5 10
AND 3 5 2
UPD 5 1
QUE 2 5
UPD 3 6
QUE 1 5
output
Copy
6
2
6

输入样例 复制

5 11
6 3 5 2 3
AND 2 4 10
UPD 1 8
AND 3 4 7
UPD 1 6
QUE 1 4
AND 3 5 10
AND 3 5 2
UPD 5 1
QUE 2 5
UPD 3 6
QUE 1 5

输出样例 复制

6
2
6