#include <bits/stdc++.h>
using namespace std;
int n, m;
long long ans, sum[100009];
bool bit[100009][18];
int main() {
  set<int> z[18];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + i;
  int h[18];
  memset(h, 0, sizeof(h));
  for (int i = 0, k; i < n; i++) {
    cin >> k;
    for (int j = 0; j < 18; j++) {
      if (1 << j & k) {
        bit[i][j] = true;
        h[j]++;
      } else {
        ans += sum[h[j]] * (1 << j);
        h[j] = 0;
        z[j].insert(i);
      }
    }
  }
  for (int i = 0; i < 18; i++) {
    if (h[i] > 0) ans += sum[h[i]] * (1 << i);
  }
  for (int i = 0, p, v; i < m; i++) {
    cin >> p >> v;
    p--;
    for (int j = 0, l, r; j < 18; j++) {
      bool b = ((1 << j & v) > 0);
      if (bit[p][j] == b)
        continue;
      else {
        bit[p][j] = b;
        if (b == true) {
          set<int>::iterator i = z[j].lower_bound(p);
          set<int>::iterator k = i;
          if (i == z[j].begin())
            l = -1;
          else {
            k--;
            l = *k;
          }
          k = i;
          i++;
          if (i == z[j].end())
            r = n;
          else
            r = *i;
          z[j].erase(k);
          long long ad = sum[r - l - 1] - sum[p - l - 1] - sum[r - p - 1];
          ans = ans + ad * (1 << j);
        } else {
          set<int>::iterator i = z[j].lower_bound(p);
          set<int>::iterator k = i;
          if (i == z[j].end())
            r = n;
          else
            r = *i;
          if (i == z[j].begin())
            l = -1;
          else {
            k--;
            l = *k;
          }
          z[j].insert(p);
          long long ad = sum[p - l - 1] + sum[r - p - 1] - sum[r - l - 1];
          ans = ans + ad * (1 << j);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
