#include <bits/stdc++.h>
using namespace std;
set<int> S[20];
long long ans[20];
int arr[100001][20];
void ins(set<int> &s, int ind, int p2) {
  set<int>::iterator it = s.lower_bound(ind);
  int r = *it;
  it--;
  int l = *it;
  s.insert(ind);
  long long range = r - l - 1;
  ans[p2] -= (range * (range + 1)) / 2;
  range = ind - l - 1;
  ans[p2] += (range * (range + 1)) / 2;
  range = r - ind - 1;
  ans[p2] += (range * (range + 1)) / 2;
}
void er(set<int> &s, int ind, int p2) {
  set<int>::iterator it = s.upper_bound(ind);
  int r = *it;
  --it;
  --it;
  int l = *it;
  long long range = ind - l - 1;
  ans[p2] -= (range * (range + 1)) / 2;
  range = r - ind - 1;
  ans[p2] -= (range * (range + 1)) / 2;
  range = r - l - 1;
  ans[p2] += (range * (range + 1)) / 2;
  s.erase(ind);
}
int main() {
  int n, m, in, x, ind;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < 20; ++i) {
    ans[i] = ((long long)n * (long long)(n + 1)) / 2LL;
    S[i].insert(-1);
    S[i].insert(n);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &in);
    for (int j = 0; j < 20; ++j) {
      arr[i][j] = (in >> j) & 1;
      if (arr[i][j] == 0) ins(S[j], i, j);
    }
  }
  while (m--) {
    long long qans = 0;
    scanf("%d %d", &ind, &x);
    ind--;
    for (int j = 0; j < 20; ++j) {
      int curr = (x >> j) & 1;
      if (curr == arr[ind][j])
        continue;
      else {
        arr[ind][j] = curr;
        if (curr == 0)
          ins(S[j], ind, j);
        else
          er(S[j], ind, j);
      }
    }
    for (int j = 0; j < 20; ++j) qans += 1LL * (1LL << j) * (long long)ans[j];
    printf("%lld\n", qans);
  }
}
