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 a[111111];
set<pair<int, int> > s[20];
set<pair<int, int> >::iterator it;
int N, M;
long long ans;
long long calc(int x, int i) { return (1LL << i) * x * (x + 1) / 2; }
void pre() {
  for (int i = 0; i < 20; i++) {
    for (int j = 0, st, ed; j < N; j++) {
      if (!(a[j] & (1 << i))) continue;
      st = j, ed = j;
      while (ed < N && a[ed] & (1 << i)) ed++;
      j = ed - 1;
      s[i].insert(pair<int, int>(st, ed));
      ans += calc(ed - st, i);
    }
    s[i].insert(pair<int, int>(-1, -1));
    s[i].insert(pair<int, int>(111111, 111111));
  }
}
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", a + i);
  }
  pre();
  int p, v;
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &p, &v);
    p--;
    for (int j = 0; j < 20; j++, v >>= 1) {
      if (v & 1) {
        it = s[j].lower_bound(pair<int, int>(p, 0));
        pair<int, int> sec = *it;
        it--;
        pair<int, int> fir = *it;
        if (sec.first == p || fir.second > p) continue;
        if (sec.first == p + 1) {
          s[j].erase(sec);
          ans -= calc(sec.second - sec.first, j);
          sec.first--;
          s[j].insert(sec);
          ans += calc(sec.second - sec.first, j);
        } else
          s[j].insert(sec = pair<int, int>(p, p + 1)), ans += calc(1, j);
        if (fir.second == sec.first) {
          s[j].erase(fir), s[j].erase(sec);
          ans -= calc(fir.second - fir.first, j);
          ans -= calc(sec.second - sec.first, j);
          ans += calc(sec.second - fir.first, j);
          s[j].insert(pair<int, int>(fir.first, sec.second));
        }
      } else {
        it = s[j].lower_bound(pair<int, int>(p, 0));
        if (it->first > p) it--;
        if (it->second <= p) continue;
        pair<int, int> tp = *it;
        s[j].erase(it);
        ans -= calc(tp.second - tp.first, j);
        if (tp.first < p) {
          s[j].insert(pair<int, int>(tp.first, p));
          ans += calc(p - tp.first, j);
        }
        if (p + 1 < tp.second) {
          s[j].insert(pair<int, int>(p + 1, tp.second));
          ans += calc(tp.second - p - 1, j);
        }
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}