#include <iostream>
#include <vector>
using namespace std;
const int MAXN = 1 << 17; // Số phần tử tối đa (2^17)
long long tree[4 * MAXN]; // Mảng lưu trữ cây phân đoạn
int n, m; // Số cấp độ và số truy vấn
int N; // Tổng số phần tử (2^n)
vector<long long> arr; // Dãy số ban đầu
// Hàm xây dựng cây phân đoạn
void build(int node, int left, int right, int height) {
if (left == right) {
tree[node] = arr[left];
} else {
int mid = (left + right) / 2;
build(2 * node, left, mid, height - 1);
build(2 * node + 1, mid + 1, right, height - 1);
if (height % 2 == 0) {
// Mức chẵn -> Phép OR
tree[node] = tree[2 * node] | tree[2 * node + 1];
} else {
// Mức lẻ -> Phép XOR
tree[node] = tree[2 * node] ^ tree[2 * node + 1];
}
}
}
// Hàm cập nhật cây phân đoạn
void update(int node, int left, int right, int index, long long value, int height) {
if (left == right) {
tree[node] = value;
} else {
int mid = (left + right) / 2;
if (index <= mid) {
update(2 * node, left, mid, index, value, height - 1);
} else {
update(2 * node + 1, mid + 1, right, index, value, height - 1);
}
if (height % 2 == 0) {
// Mức chẵn -> Phép OR
tree[node] = tree[2 * node] | tree[2 * node + 1];
} else {
// Mức lẻ -> Phép XOR
tree[node] = tree[2 * node] ^ tree[2 * node + 1];
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
N = 1 << n;
arr.resize(N + 1); // Chỉ số bắt đầu từ 1
for (int i = 1; i <= N; ++i) {
cin >> arr[i];
}
build(1, 1, N, n);
for (int i = 0; i < m; ++i) {
int p;
long long b;
cin >> p >> b;
update(1, 1, N, p, b, n);
cout << tree[1] << '\n';
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWE4gPSAxIDw8IDE3OyAvLyBT4buRIHBo4bqnbiB04butIHThu5FpIMSRYSAoMl4xNykKbG9uZyBsb25nIHRyZWVbNCAqIE1BWE5dOyAvLyB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ZCgxLCAxLCBOLCBuKTsKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG07ICsraSkgewogICAgICAgIGludCBwOwogICAgICAgIGxvbmcgbG9uZyBiOwogICAgICAgIGNpbiA+PiBwID4+IGI7CiAgICAgICAgdXBkYXRlKDEsIDEsIE4sIHAsIGIsIG4pOwogICAgICAgIGNvdXQgPDwgdHJlZVsxXSA8PCAnXG4nOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==