#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500000 + 100;
;
int ans[20][MAXN];
int n;
int ok(int m, int p, int x) {
  ans[1][p] = x;
  p = (p / 2) + (p % 2);
  for (int i = 2; i <= n + 1; i++) {
    if (i % 2 == 0)
      ans[i][p] = ans[i - 1][(p - 1) * 2 + 1] | ans[i - 1][(p - 1) * 2 + 2];
    else
      ans[i][p] = ans[i - 1][(p - 1) * 2 + 1] ^ ans[i - 1][(p - 1) * 2 + 2];
    p = (p / 2) + (p % 2);
  }
  return ans[n + 1][1];
}
int main() {
  int m;
  cin >> n >> m;
  for (int i = 1; i <= (1 << n); i++) cin >> ans[1][i];
  for (int i = 2; i <= n + 1; i++)
    for (int j = 0; j < (1 << (n - i + 1)); j++) {
      if (i % 2 == 0)
        ans[i][j + 1] = ans[i - 1][2 * j + 1] | ans[i - 1][2 * j + 2];
      else
        ans[i][j + 1] = ans[i - 1][2 * j + 1] ^ ans[i - 1][2 * j + 2];
    }
  for (int i = 1; i <= m; i++) {
    int p, b;
    cin >> p >> b;
    int ans = ok(1, p, b);
    cout << ans << endl;
  }
  return 0;
}
