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;
int n, m;
int a[32][100005], b[32][100005 * 4], c[32][100005 * 4];
long long s[32][100005 * 4];
long long get(long long x) { return (x + 1) * x / 2; }
void maintain(int t, int k, int l, int r) {
  long long f1 = get(c[t][k * 2]);
  long long f2 = get(b[t][k * 2 + 1]);
  long long f3 = get(c[t][k * 2] + b[t][k * 2 + 1]);
  int mid = (l + r) / 2;
  b[t][k] = b[t][k * 2];
  c[t][k] = c[t][k * 2 + 1];
  if (b[t][k * 2] == mid - l + 1) b[t][k] += b[t][k * 2 + 1];
  if (c[t][k * 2 + 1] == r - mid) c[t][k] += c[t][k * 2];
  s[t][k] = s[t][k * 2] + s[t][k * 2 + 1] - f1 - f2 + f3;
}
void build(int t, int k, int l, int r) {
  if (l == r) {
    s[t][k] = b[t][k] = c[t][k] = a[t][l];
    return;
  }
  int mid = (l + r) / 2;
  build(t, k * 2, l, mid);
  build(t, k * 2 + 1, mid + 1, r);
  maintain(t, k, l, r);
}
void change(int t, int k, int l, int r, int x) {
  if (l == r) {
    s[t][k] = b[t][k] = c[t][k] = a[t][l];
    return;
  }
  int mid = (l + r) / 2;
  if (x <= mid) change(t, k * 2, l, mid, x);
  if (x > mid) change(t, k * 2 + 1, mid + 1, r, x);
  maintain(t, k, l, r);
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    for (int j = 0; x; x >>= 1, j++) {
      a[j][i] = x & 1;
    }
  }
  for (int i = 0; i < 32; i++) build(i, 1, 1, n);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    for (int j = 0; j < 32; j++) {
      int z = ((1 << j) & y) > 0;
      if (z != a[j][x]) {
        a[j][x] = z;
        change(j, 1, 1, n, x);
      }
    }
    long long ans = 0;
    for (int j = 0; j < 32; j++) {
      long long z = (1 << j);
      ans += z * s[j][1];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}