#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 2n2^n 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 vv remains. After each of mm point updates, print the new vv.

Input

  • The first line contains nn and mm.
  • The second line contains 2n2^n values a1,a2,…,a2na_1,a_2,\ldots,a_{2^n} with 0≤ai<2300 \le a_i<2^{30}.
  • Each of the next mm lines contains pp and bb, meaning ap=ba_p=b, with 1≤p≤2n1 \le p \le 2^n and 0≤b<2300 \le b<2^{30}.

Output

After each update, print the current value vv on its own line.

Subtasks

  • Subtask 1 — 20%: 1≤n≤101 \le n \le 10, 1≤m≤10001 \le m \le 1000.
  • Subtask 2 — 30%: 1≤n≤151 \le n \le 15, 1≤m≤500001 \le m \le 50000.
  • Subtask 3 — 50%: 1≤n≤171 \le n \le 17, 1≤m≤1051 \le m \le 10^5.

Examples

Input

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

Output

1
3
3
3

Explanation

For n=2n=2, the level directly above the array uses OR and the root level uses XOR. After the first update, the array is 4,6,3,54,6,3,5: the intermediate values are 4 ∣ 6=64\,|\,6=6 and 3 ∣ 5=73\,|\,5=7, hence v=6 ^ 7=1v=6\,\hat{}\,7=1. The later updates produce 3,3,33,3,3.