Problem: Inna is fed up with jokes about female logic. So she started using binary logic instead.

Inna has an array of n elements a1[1], a1[2], ..., a1[n]. Girl likes to train in her binary logic, so she does an exercise consisting of n stages: on the first stage Inna writes out all numbers from array a1, on the i-th (i ≥ 2) stage girl writes all elements of array ai, which consists of n - i + 1 integers; the k-th integer of array ai is defined as follows: ai[k] = ai - 1[k] AND ai - 1[k + 1]. Here AND is bit-wise binary logical operation.

Dima decided to check Inna's skill. He asks Inna to change array, perform the exercise and say the sum of all <image> elements she wrote out during the current exercise.

Help Inna to answer the questions!

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105) — size of array a1 and number of Dima's questions. Next line contains n integers a1[1], a1[2], ..., a1[n] (0 ≤ ai ≤ 105) — initial array elements.

Each of next m lines contains two integers — Dima's question description. Each question consists of two integers pi, vi (1 ≤ pi ≤ n; 0 ≤ vi ≤ 105). For this question Inna should make a1[pi] equals vi, and then perform the exercise. Please, note that changes are saved from question to question.

Output

For each question print Inna's answer on a single line.

Examples

Input

3 4
1 1 1
1 1
2 2
3 2
1 2


Output

6
4
7
12

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct data {
  int p, v;
};
int n, m;
int a[110000], b[110000];
data d[110000];
int f[110000];
long long ans[110000];
void add(int x, int y) {
  while (x <= n) {
    f[x] += y;
    x += (x & (-x));
  }
}
int quest(int x) {
  int ret = 0;
  while (x > 0) {
    ret += f[x];
    x -= (x & (-x));
  }
  return ret;
}
long long findleft(int le, int ri) {
  int rr = quest(ri), R = ri;
  long long mid, ans = ri;
  int c;
  while (le <= ri) {
    mid = (le + ri) / 2;
    c = rr - quest(mid - 1);
    if (c == R - mid + 1) {
      ans = mid;
      ri = mid - 1;
    } else {
      le = mid + 1;
    }
  }
  return ans;
}
long long findright(int le, int ri) {
  long long mid, ans = le;
  int c, lle = quest(le - 1), L = le;
  while (le <= ri) {
    mid = (le + ri) / 2;
    c = quest(mid) - lle;
    if (c == mid - L + 1) {
      ans = mid;
      le = mid + 1;
    } else {
      ri = mid - 1;
    }
  }
  return ans;
}
void solve(int x) {
  long long tmp = 0, c = 0;
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++) {
    if (a[i] & x) {
      b[i] = 1;
      add(i, 1);
      ++c;
      tmp += c;
    } else
      b[i] = c = 0;
  }
  long long le, ri;
  for (int i = 0; i < m; i++) {
    if (d[i].v & x) {
      if (b[d[i].p] == 0) {
        b[d[i].p] = 1;
        add(d[i].p, 1);
        le = findleft(1, d[i].p);
        ri = findright(d[i].p, n);
        tmp -= (d[i].p - le + 1) * (d[i].p - le) / 2;
        tmp -= (ri - d[i].p + 1) * (ri - d[i].p) / 2;
        tmp += (ri - le + 2) * (ri - le + 1) / 2;
      }
    } else {
      if (b[d[i].p] == 1) {
        le = findleft(1, d[i].p);
        ri = findright(d[i].p, n);
        tmp -= (ri - le + 2) * (ri - le + 1) / 2;
        tmp += (d[i].p - le + 1) * (d[i].p - le) / 2;
        tmp += (ri - d[i].p + 1) * (ri - d[i].p) / 2;
        b[d[i].p] = 0;
        add(d[i].p, -1);
      }
    }
    ans[i] += tmp * x;
  }
}
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) scanf("%d%d", &d[i].p, &d[i].v);
}
int main() {
  init();
  for (int i = 0; (1 << i) < 100000; i++) solve(1 << i);
  for (int i = 0; i < m; i++) cout << ans[i] << endl;
  return 0;
}