#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 1;
int n, m;
int a[maxn];
int p, v;
int s, f;
long long koyta[20];
int run[20][maxn];
map<int, int> start[20];
map<int, int> finish[20];
long long cal() {
  long long ans = 0LL;
  long long p2 = 1;
  for (int i = 0; i < 20; i++) {
    ans += p2 * koyta[i];
    p2 <<= 1;
  }
  return ans;
}
long long F(long long x) { return x * (x + 1) / 2; }
int lsize, rsize, totsize;
int ls, lf;
int rs, rf;
int ts, tf;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    for (int j = 0; j < 20; j++)
      if ((a[i] >> j) & 1) run[j][i] = 1;
  }
  for (int j = 0; j < 20; j++) {
    for (int i = 0; i < n; i++) {
      if (run[j][i] == 1) {
        s = i;
        f = i;
        while (i + 1 < n && run[j][i + 1] == 1) i++, f = i;
        start[j][s] = f;
        finish[j][f] = s;
        koyta[j] += F(f - s + 1);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &p, &v);
    p--;
    for (int j = 0; j < 20; j++) {
      if ((v >> j) & 1) {
        if (run[j][p] == 1) continue;
        run[j][p] = 1;
        if (p - 1 >= 0 && p + 1 < n && run[j][p - 1] == 1 &&
            run[j][p + 1] == 1) {
          lsize = 0;
          rsize = 0;
          ls;
          lf = p - 1;
          ls = finish[j][lf];
          lsize = lf - ls + 1;
          start[j].erase(ls);
          finish[j].erase(lf);
          rs = p + 1;
          rf;
          rf = start[j][rs];
          rsize = rf - rs + 1;
          start[j].erase(rs);
          finish[j].erase(rf);
          start[j][ls] = rf;
          finish[j][rf] = ls;
          koyta[j] -= F(lsize);
          koyta[j] -= F(rsize);
          koyta[j] += F(lsize + rsize + 1);
        } else if (p - 1 >= 0 && run[j][p - 1] == 1 &&
                   (p + 1 >= n or (p + 1 < n && run[j][p + 1] == 0))) {
          lsize = 0;
          ls;
          lf = p - 1;
          ls = finish[j][lf];
          lsize = lf - ls + 1;
          start[j].erase(ls);
          finish[j].erase(lf);
          start[j][ls] = p;
          finish[j][p] = ls;
          koyta[j] -= F(lsize);
          koyta[j] += F(lsize + 1);
        } else if (p + 1 < n && run[j][p + 1] == 1 &&
                   (p - 1 < 0 or (p - 1 >= 0 && run[j][p - 1] == 0))) {
          rsize = 0;
          rs = p + 1;
          rf;
          rf = start[j][rs];
          rsize = rf - rs + 1;
          start[j].erase(rs);
          finish[j].erase(rf);
          start[j][p] = rf;
          finish[j][rf] = p;
          koyta[j] -= F(rsize);
          koyta[j] += F(rsize + 1);
        } else {
          start[j][p] = p;
          finish[j][p] = p;
          koyta[j] += F(1);
        }
      } else {
        if (run[j][p] == 0) continue;
        run[j][p] = 0;
        if (p - 1 >= 0 && p + 1 < n && run[j][p - 1] == 1 &&
            run[j][p + 1] == 1) {
          totsize = 0;
          lsize = 0;
          rsize = 0;
          auto itr = finish[j].lower_bound(p);
          rf = itr->first;
          ls = itr->second;
          totsize = rf - ls + 1;
          start[j].erase(ls);
          finish[j].erase(rf);
          lf = p - 1;
          lsize = lf - ls + 1;
          start[j][ls] = lf;
          finish[j][lf] = ls;
          rs = p + 1;
          rsize = rf - rs + 1;
          start[j][rs] = rf;
          finish[j][rf] = rs;
          koyta[j] -= F(totsize);
          koyta[j] += F(lsize);
          koyta[j] += F(rsize);
        } else if (p - 1 >= 0 && run[j][p - 1] == 1 &&
                   (p + 1 >= n or (p + 1 < n && run[j][p + 1] == 0))) {
          lsize = 0;
          ls;
          lf = p;
          ls = finish[j][lf];
          lsize = lf - ls + 1;
          start[j].erase(ls);
          finish[j].erase(lf);
          start[j][ls] = p - 1;
          finish[j][p - 1] = ls;
          koyta[j] -= F(lsize);
          koyta[j] += F(lsize - 1);
        } else if (p + 1 < n && run[j][p + 1] == 1 &&
                   (p - 1 < 0 or (p - 1 >= 0 && run[j][p - 1] == 0))) {
          rsize = 0;
          rs = p;
          rf;
          rf = start[j][rs];
          rsize = rf - rs + 1;
          start[j].erase(rs);
          finish[j].erase(rf);
          start[j][p + 1] = rf;
          finish[j][rf] = p + 1;
          koyta[j] -= F(rsize);
          koyta[j] += F(rsize - 1);
        } else {
          start[j].erase(p);
          finish[j].erase(p);
          koyta[j] -= F(1);
        }
      }
    }
    printf("%I64d\n", cal());
  }
  return 0;
}
