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;
const int inf = 1e9 + 10;
const long long INF = 4e18 + 10;
const int maxn = 1e5 + 5;
const int maxbit = 32;
struct Block {
  int lb, rb, sz;
  bool operator<(const Block& rhs) const {
    if (lb != rhs.lb)
      return lb < rhs.lb;
    else if (rb != rhs.rb)
      return rb < rhs.rb;
    return sz < rhs.sz;
  }
};
long long sum(int x) { return (1LL * x * (x + 1)) / 2; }
void print(int* a, int n) {
  for (int i = 0; i < n; ++i) printf("%d", a[i]);
  puts("");
}
int series[32][maxn];
set<Block> blocks[32];
int a[maxn];
int n, m;
long long tot;
int MAIN() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    for (int bit = 0; bit < maxbit; ++bit) {
      if (a[i] & (1 << bit)) series[bit][i] = 1;
    }
  }
  for (int bit = 0; bit < maxbit; ++bit) {
    int mask = (1 << bit);
    int sz = 1, lft = 0;
    for (int i = 0; i < n; ++i) {
      if (i == n - 1 || series[bit][i] != series[bit][i + 1]) {
        if ((mask & a[i])) {
          blocks[bit].insert((Block){lft, i, sz});
          tot += (1 << bit) * sum(sz);
        }
        sz = 1, lft = i + 1;
      } else {
        ++sz;
      }
    }
  }
  while (m--) {
    int p, v;
    scanf("%d%d", &p, &v);
    --p;
    for (int bit = 0; bit < maxbit; ++bit) {
      int mask = (1 << bit);
      if ((a[p] & mask) == (v & mask)) continue;
      if (v & mask) {
        set<Block>::iterator lft = blocks[bit].lower_bound((Block){p, 0, 0});
        set<Block>::iterator rgt = lft;
        int nw_lft = p, nw_rgt = p, nw_sz = 1;
        bool er = false;
        if (rgt != blocks[bit].end() && rgt->lb == p + 1) {
          nw_sz += rgt->sz;
          nw_rgt = rgt->rb;
          tot -= (mask * sum(rgt->sz));
          er = true;
        }
        if (rgt != blocks[bit].begin()) {
          --lft;
          if (lft->rb == p - 1) {
            nw_sz += lft->sz;
            nw_lft = lft->lb;
            tot -= (mask * sum(lft->sz));
            blocks[bit].erase(lft);
          }
        }
        if (er) blocks[bit].erase(rgt);
        tot += (mask * sum(nw_sz));
        blocks[bit].insert((Block){nw_lft, nw_rgt, nw_sz});
      } else {
        set<Block>::iterator it = blocks[bit].lower_bound((Block){p, 0, 0});
        if (it == blocks[bit].end() || it->lb > p) --it;
        tot -= (mask * sum(it->sz));
        if (p + 1 <= it->rb) {
          int sz = it->rb - p;
          tot += (mask * sum(sz));
          blocks[bit].insert((Block){p + 1, it->rb, sz});
        }
        if (p - 1 >= it->lb) {
          int sz = p - it->lb;
          tot += (mask * sum(sz));
          blocks[bit].insert((Block){it->lb, p - 1, sz});
        }
        blocks[bit].erase(it);
      }
    }
    a[p] = v;
    printf("%I64d\n", tot);
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  int ret = MAIN();
  return ret;
}