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 long long N = 100101, M = (long long)1e9 + 7, inf = INT_MAX;
const long long INF = LLONG_MAX;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  if (0) return;
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  if (0) return;
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long mxbit = 18;
long long arr[N], val[mxbit][N], total = 0;
long long get(long long x) { return (x * (x + 1)) / 2; }
set<pair<long long, long long> > stt[mxbit];
void insert(long long j, long long l, long long r) {
  if (r < l) return;
  long long p = (1LL << j);
  total += get(r - l + 1) * p;
  stt[j].insert({l, r});
}
void solve() {
  long long n, q;
  cin >> n >> q;
  for (long long i = 0; i < (long long)n; i++) {
    cin >> arr[i];
    for (long long j = 0; j < (long long)mxbit; j++) {
      if ((arr[i] & 1LL << j)) val[j][i] = 1;
    }
  }
  for (long long j = 0; j < (long long)mxbit; j++) {
    long long st = -1;
    for (long long i = 0; i < (long long)n; i++) {
      if (val[j][i] == 0) {
        if (st != -1) insert(j, st, i - 1);
        st = -1;
      } else {
        if (st == -1) st = i;
      }
    }
    if (st != -1) insert(j, st, n - 1);
  }
  while (q--) {
    long long id, x, p = 1;
    cin >> id >> x;
    id--;
    pair<long long, long long> ch = {id, id};
    for (long long j = 0; j < (long long)mxbit; j++) {
      bool f = (x & (1LL << j));
      if (f != val[j][id]) {
        auto it = stt[j].lower_bound(ch);
        if (f == 1) {
          long long l = id, r = id;
          vector<pair<long long, long long> > rem;
          if (it != stt[j].end() and it->first == r + 1) {
            r = it->second;
            rem.push_back(*it);
            stt[j].erase(it);
          }
          it = stt[j].lower_bound(ch);
          if (it != stt[j].begin()) {
            it--;
            if (it->second == l - 1) {
              l = it->first;
              rem.push_back(*it);
              stt[j].erase(it);
            }
          }
          for (auto& k : rem) total -= get(k.second - k.first + 1) * p;
          insert(j, l, r);
        } else {
          if (it == stt[j].end() or it->first != id) it--;
          long long len = it->second - it->first + 1;
          total -= get(len) * p;
          pair<long long, long long> p = *it;
          stt[j].erase(it);
          insert(j, p.first, id - 1), insert(j, id + 1, p.second);
        }
      }
      val[j][id] = f;
      p *= 2;
    }
    cout << total << '\n';
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  while (test--) solve();
}