#SGM0000006. Xenia và các phép toán bit (Xenia and Bit Operations)
Xenia và các phép toán bit (Xenia and Bit Operations)
Xenia and Bit Operations
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A sequence contains non-negative integers. On the first reduction level, adjacent pairs are combined with bitwise OR; on the next level they are combined with bitwise XOR; OR and XOR then alternate until one value remains. After each of point updates, print the new .
Input
- The first line contains and .
- The second line contains values with .
- Each of the next lines contains and , meaning , with and .
Output
After each update, print the current value on its own line.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , .
Examples
Input
2 4
1 6 3 5
1 4
3 4
1 2
1 2
Output
1
3
3
3
Explanation
For , the level directly above the array uses OR and the root level uses XOR. After the first update, the array is : the intermediate values are and , hence . The later updates produce .