#include <bits/stdc++.h>
using namespace std;
typedef struct xx {
  long long val;
  long long op;
  struct xx *right, *left;
} node;
node* nnode() {
  node* temp = (node*)malloc(sizeof(node));
  temp->val = -1;
  temp->op = -1;
  temp->left = NULL;
  temp->right = NULL;
  return temp;
}
long long dfs(node* root, long long depth) {
  if (depth == 0) {
    long long x;
    cin >> x;
    root->val = x;
    return x;
  }
  root->left = nnode();
  root->left->op = root->op ^ 1;
  root->right = nnode();
  root->right->op = root->op ^ 1;
  long long a = dfs(root->left, depth - 1);
  long long b = dfs(root->right, depth - 1);
  if (root->op == 1)
    root->val = a | b;
  else
    root->val = a ^ b;
  return root->val;
}
long long hi;
long long update(node* root, long long x, long long y, long long temp) {
  if (temp == 0) {
    root->val = y;
    return y;
  }
  if (x > temp) {
    long long a = update(root->right, x - temp, y, temp / 2);
    if (root->op == 1)
      root->val = (root->left->val) | a;
    else
      root->val = (root->left->val) ^ a;
    return root->val;
  } else {
    long long a = update(root->left, x, y, temp / 2);
    if (root->op == 1)
      root->val = (root->right->val) | a;
    else
      root->val = (root->right->val) ^ a;
    return root->val;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  hi = 1 << n;
  node* root = nnode();
  if (n % 2 == 1)
    root->op = 1;
  else
    root->op = 0;
  long long temp = dfs(root, n);
  while (m--) {
    long long x, y;
    cin >> x >> y;
    cout << update(root, x, y, hi / 2) << endl;
  }
  return 0;
}
