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 N = 100001;
const int D = 17;
const int MD = 1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double EPS = 1E-6;
long long calc(int len) { return (long long)len * (len + 1) / 2; }
struct Tree {
  struct Node {
    int l, r;
    int lo, ro;
    long long sum;
    Node() {}
    Node(int l, int r) : l(l), r(r) {
      lo = ro = r - l + 1;
      sum = 0;
    }
    bool L() { return lo == r - l + 1; }
    bool R() { return ro == r - l + 1; }
  } v[N * 4];
  int root;
  int l, r;
  long long sum;
  void update(int now) {
    v[now].sum = 0;
    if (v[now].l == v[now].r) return;
    v[now].sum = v[now * 2].sum + v[now * 2 + 1].sum;
    if (v[now * 2].L())
      v[now].lo = v[now * 2].lo + v[now * 2 + 1].lo;
    else
      v[now].lo = v[now * 2].lo;
    if (v[now * 2 + 1].R())
      v[now].ro = v[now * 2 + 1].ro + v[now * 2].ro;
    else
      v[now].ro = v[now * 2 + 1].ro;
    if (!v[now * 2].R() && !v[now * 2 + 1].L()) {
      v[now].sum += calc(v[now * 2].ro + v[now * 2 + 1].lo);
    }
  }
  void change(int now, int pos, int val) {
    if (v[now].l == v[now].r) {
      v[now].lo = v[now].ro = val;
    } else {
      int mid = (v[now].l + v[now].r) / 2;
      if (pos <= mid)
        change(now * 2, pos, val);
      else
        change(now * 2 + 1, pos, val);
    }
    update(now);
  }
  void change(int pos, int val) {
    pos++;
    change(root, pos, val);
    sum = v[root].sum + calc(v[root].lo) + calc(v[root].ro);
    if (v[root].L()) sum -= calc(v[root].lo);
  }
  long long ask() { return sum; }
  void build(int now, int l, int r) {
    v[now] = Node(l, r);
    if (l == r) return;
    int mid = (l + r) / 2;
    build(now * 2, l, mid);
    build(now * 2 + 1, mid + 1, r);
    update(now);
  }
  void init(int n) {
    l = 1, r = n;
    root = 1;
    build(1, l, r);
    sum = v[root].sum + calc(v[root].lo) + calc(v[root].ro);
    if (v[root].L()) sum -= calc(v[root].lo);
  }
} t[D];
int n, m;
int l[D][N], r[D][N];
int val[D][N];
long long ans;
void init() {
  scanf("%d%d", &n, &m);
  for (int j = 0; j < (D); j++) t[j].init(n);
  for (int i = 0; i < (n); i++) {
    int x;
    scanf("%d", &x);
    for (int j = 0; j < (D); j++) {
      t[j].change(i, (x & (1 << j)) != 0);
    }
  }
  ans = 0;
  for (int j = 0; j < (D); j++) ans += ((1 << j) * t[j].ask());
}
void solve() {
  for (int i = 0; i < (m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    for (int j = 0; j < (D); j++) {
      ans -= (1 << j) * t[j].ask();
      t[j].change(x, (y & (1 << j)) != 0);
      ans += (1 << j) * t[j].ask();
    }
    cout << ans << endl;
  }
}
int main() {
  init();
  solve();
  return 0;
}