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 wie {
  long long s, pref, suf;
};
vector<vector<wie> > T(17);
int l, size;
wie Merge(wie a, wie b, int wlk) {
  wie wyn;
  wyn.s = a.s + b.s;
  wyn.s -= (1 + a.suf) * a.suf / 2;
  wyn.s -= (1 + b.pref) * b.pref / 2;
  wyn.s += (1 + (a.suf + b.pref)) * (a.suf + b.pref) / 2;
  if (a.pref < wlk)
    wyn.pref = a.pref;
  else
    wyn.pref = a.pref + b.pref;
  if (b.suf < wlk)
    wyn.suf = b.suf;
  else
    wyn.suf = b.suf + a.suf;
  return wyn;
}
void Stworz(int n) {
  int p = 1;
  while (p < n) p *= 2;
  l = p;
  size = 2 * p - 1;
  for (int i = 0; i < 17; ++i)
    for (int j = 0; j <= size; ++j) T[i].push_back({0, 0, 0});
}
void Zmien(int nr, int a, int x) {
  a += l;
  T[nr][a] = {x, x, x};
  a /= 2;
  int wlk = 1;
  while (a != 0) {
    T[nr][a] = Merge(T[nr][2 * a], T[nr][2 * a + 1], wlk);
    a /= 2;
    wlk *= 2;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  Stworz(n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 17; ++j)
      if ((a[i] & (1 << j)) > 0) Zmien(j, i, 1);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    for (int j = 0; j < 17; ++j) {
      if ((y & (1 << j)) > 0)
        Zmien(j, x, 1);
      else
        Zmien(j, x, 0);
    }
    long long odp = 0;
    for (int j = 0; j < 17; ++j) odp += T[j][1].s * (1 << j);
    cout << odp << endl;
  }
  return 0;
}