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 <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int mod = 1e9 + 7;
const int maxn = 100005;
const int inf = 1 << 30;
const int bits = 18;
template <typename T>
class SegmentTree {
 public:
  vector<T> ST, lazy;
  int n;
  T base_value;
  SegmentTree() {
    this->n = maxn;
    base_value = -inf;
    int h = ceil(log2(n));
    ST.resize((1 << (h + 1)), base_value);
    lazy.resize((1 << (h + 1)), 0);
  }
  T F(T a, T b) { return max(a, b); }
  void propagate(int ini, int fin, int i, T val) {
    ST[i] = val;
    if (ini != fin) {
      lazy[i * 2] = val;
      lazy[i * 2 + 1] = val;
    }
  }
  void update(int i, int ini, int fin, int l, int r, T val) {
    if (lazy[i] != 0) {
      propagate(ini, fin, i, lazy[i]);
      lazy[i] = 0;
    }
    if (fin < l || r < ini) return;
    if (ini >= l && fin <= r) {
      propagate(ini, fin, i, val);
      return;
    }
    int m = (ini + fin) / 2;
    update(2 * i, ini, m, l, r, val);
    update(2 * i + 1, m + 1, fin, l, r, val);
    ST[i] = F(ST[i * 2], ST[i * 2 + 1]);
  }
  void update(int l, int r, T val) { update(1, 1, n, l, r, val); }
  T query(int i, int ini, int fin, int l, int r) {
    if (lazy[i] != 0) {
      propagate(ini, fin, i, lazy[i]);
      lazy[i] = 0;
    }
    if (fin < l || r < ini) return base_value;
    if (ini >= l && fin <= r) return ST[i];
    int m = (ini + fin) / 2;
    T izq = query(2 * i, ini, m, l, r);
    T der = query(2 * i + 1, m + 1, fin, l, r);
    return F(izq, der);
  }
  T query(int l, int r) { return query(1, 1, n, l, r); }
};
int a[maxn][bits];
SegmentTree<int> ini[bits], fin[bits];
long long int total;
int n, m;
long long int g(int x) { return 1ll * x * (x + 1) / 2ll; }
void add_value(int pos, int x) {
  for (int b = 0; b < bits; b++) {
    long long int valor = 1ll << b;
    if (x & (1 << b)) {
      if (a[pos][b]) continue;
      int left = pos, right = pos;
      if (pos - 1 >= 1 && a[pos - 1][b]) {
        left = min(left, ini[b].query(pos - 1, pos - 1));
        total -= valor * g((pos - 1) - left + 1);
      }
      if (pos + 1 <= n && a[pos + 1][b]) {
        right = max(right, fin[b].query(pos + 1, pos + 1));
        total -= valor * g(right - (pos + 1) + 1);
      }
      total += valor * g(right - left + 1);
      ini[b].update(left, right, left);
      fin[b].update(left, right, right);
    } else {
      if (!a[pos][b]) continue;
      int left = ini[b].query(pos, pos), right = fin[b].query(pos, pos);
      total -= valor * g(right - left + 1);
      if (pos - 1 >= 1 && a[pos - 1][b]) {
        fin[b].update(left, pos - 1, pos - 1);
        total += valor * g((pos - 1) - left + 1);
      }
      if (pos + 1 <= n && a[pos + 1][b]) {
        ini[b].update(pos + 1, right, pos + 1);
        total += valor * g(right - (pos + 1) + 1);
      }
    }
    a[pos][b] = ((x & (1 << b)) > 0);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  total = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    add_value(i, x);
  }
  while (m--) {
    int p, x;
    cin >> p >> x;
    add_value(p, x);
    cout << total << '\n';
  }
}