Problem10286--CF EDU - Segment Tree P2 - Step 2 - C. Bitwise OR and AND

10286: CF EDU - Segment Tree P2 - Step 2 - C. Bitwise OR and AND

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

There is an array of $n$ elements, initially filled with zeros. You need to write a data structure that processes two types of queries:

  • apply the operation $a_i=a_i|v$ (bitwise OR) to all elements from $l$ to $r−1$
  • find bitwise AND of elements in the range from $l$ to $r−1$.

Input

The first line contains two numbers $n,m\ (1≤n,m≤100,000)$, the size of the array and the number of operations. 

The following lines contain the description of the operations. The description of each operation is as follows:

  • 1 l r v: apply the operation $a_i=a_i|v$ (bitwise OR) to all elements from $l$ to $r−1\ (0≤l<r≤n,\ 0≤v<2^{30})$.
  • 2 l r: find bitwise AND of elements in the range from $l$ to $r−1\ (0≤l<r≤n)$.

Output

For each operation of the second type, print the corresponding value.

Sample 1 Input

5 6
1 0 3 3
2 1 2
1 1 4 4
2 1 3
2 1 4
2 3 5

Sample 1 Output

3
7
4
0

Sample 2 Input

2 3
1 0 1 3
1 1 2 9
2 0 2

Sample 2 Output

1

HINT

CF EDU.

Source/Category