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;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int N = 2 << 16;
int n, m, i, j, k, tn, l, p;
struct seg {
  long long sum[N * 4];
  int sl[N * 4], sr[N * 4];
  void upd(int i, int L) {
    sum[i] = sum[i * 2] + sum[i * 2 + 1] + (1LL * sr[i * 2] * sl[i * 2 + 1]);
    sl[i] = sl[i * 2];
    if (sl[i] == L) sl[i] += sl[i * 2 + 1];
    sr[i] = sr[i * 2 + 1];
    if (sr[i] == L) sr[i] += sr[i * 2];
  }
  void ins(int i, int x, int y, int d, int s) {
    if (x != y) {
      if (d <= (x + y) / 2)
        ins(i * 2, x, (x + y) / 2, d, s);
      else
        ins(i * 2 + 1, (x + y) / 2 + 1, y, d, s);
      upd(i, (y - x + 1) / 2);
    } else {
      sum[i] = sl[i] = sr[i] = s;
    }
  }
} T[21];
int main() {
  read(n);
  read(m);
  for (tn = 1; tn < n; tn *= 2)
    ;
  int x;
  for (i = 1; i <= n; i++) {
    read(x);
    for (j = 0; j <= 20; j++)
      if (x >> j & 1) T[j].ins(1, 1, tn, i, 1);
  }
  for (; m; m--) {
    int x, y;
    read(x);
    read(y);
    for (j = 0; j <= 20; j++) T[j].ins(1, 1, tn, x, y >> j & 1);
    long long sum = 0;
    for (j = 0; j <= 20; j++) sum += (1LL << j) * T[j].sum[1];
    printf("%I64d\n", sum);
  }
  scanf("\n");
  return 0;
}