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;
double PI = 3.141592653589793;
const int mx = 1e5 + 1, bmx = 17;
long long tree[4 * mx][bmx] = {};
int suf[4 * mx][bmx] = {}, pre[4 * mx][bmx] = {};
int n;
void update(int i, int j, int l, int r) {
  tree[i][j] = tree[i << 1][j] + tree[(i << 1) | 1][j] +
               1ll * suf[(i << 1)][j] * pre[(i << 1) | 1][j];
  int md = (l + r) >> 1;
  suf[i][j] = suf[(i << 1) | 1][j];
  if (suf[i][j] == (r - md)) suf[i][j] += suf[i << 1][j];
  pre[i][j] = pre[i << 1][j];
  if (pre[i][j] == (md - l + 1)) pre[i][j] += pre[(i << 1) | 1][j];
}
void upd(int ind, int j, int val, int i = 1, int l = 0, int r = n - 1) {
  if (l == r) {
    tree[i][j] = val;
    if (val)
      suf[i][j] = pre[i][j] = 1;
    else
      suf[i][j] = pre[i][j] = 0;
    return;
  }
  int md = (l + r) >> 1;
  if (ind <= md)
    upd(ind, j, val, i << 1, l, md);
  else
    upd(ind, j, val, (i << 1) | 1, md + 1, r);
  update(i, j, l, r);
}
void solve() {
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < bmx; j++) {
      if (k & (1 << j))
        upd(i, j, 1);
      else
        upd(i, j, 0);
    }
  }
  while (q--) {
    int p, v;
    cin >> p >> v;
    p--;
    for (int j = 0; j < bmx; j++) {
      if (v & (1 << j))
        upd(p, j, 1);
      else
        upd(p, j, 0);
    }
    long long ans = 0;
    for (int i = 0; i < bmx; i++) ans += tree[1][i] * (1ll << i);
    cout << ans << '\n';
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  for (int c = 1; c < T + 1; c++) {
    solve();
  }
}