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 JAVA):

Solution:
import java.io.*;
import java.util.*;
  
public class Main implements Runnable {
  final boolean isFileIO = false; 
  BufferedReader in;
  PrintWriter out;
  StringTokenizer st = new StringTokenizer("");
  String delim = " ";

  public static void main(String[] args) {
    new Thread(null, new Main(), "", 268435456).start(); 
  }

  public void run() {
    try {
      initIO();
      solve();
      out.close();
    } catch(Exception e) {
      e.printStackTrace(System.err);
      System.exit(-1);
    }
  }

  public void initIO() throws IOException {
    if(!isFileIO) {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(System.out);
    } else {
      in = new BufferedReader(new FileReader("input.txt"));
      out = new PrintWriter("output.txt"); 
    }
  }
  
  String nextToken() throws IOException {
    if(!st.hasMoreTokens()) {
      st = new StringTokenizer(in.readLine());
    }
    return st.nextToken(delim);
  }
 
  String readLine() throws IOException {
    return in.readLine();
  }

  int nextInt() throws IOException {
   return Integer.parseInt(nextToken());
  }

  long nextLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  double nextDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }
  
  class Segment implements Comparable <Segment> {
    public long x, c;
 
    public Segment(long x, long c) {
      this.x = x;
      this.c = c;
    }   
 
    public int compareTo(Segment b) {
      if(this.x > b.x) return 1;
      if(this.x < b.x) return -1;
      return 0;
    }
  } 
 
  void solve() throws IOException {
    int n, m;
    n = nextInt(); m = nextInt();
    final int log = 20;
    long[] a = new long[n];
    long[] s = new long[log + 1];
    for(int i = 0; i < n; i++)
      a[i] = nextInt();
    TreeSet<Segment>[] trees = new TreeSet[log + 1];
    for(int i = 0; i <= log; i++)
      trees[i] = new TreeSet<Segment>();
    for(int i = 0; i <= log; i++) {
      int c = 1 << i;
      for(int j = 0, z = 0; j < n;) {
        for(z = j; z < n; z++) {
          if((a[z] & c) != c) break;
        }
        if(z - j > 0)
          trees[i].add(new Segment(j, z - j));
        s[i] += (((long)(z - j + 1) * (long)(z - j)) * (long) c) / 2;
        j = z + 1;
      }
    }
    for(int i = 0; i < m; i++) {
      int p = nextInt() - 1; int v = nextInt();
      Segment t = new Segment(p, 0);
      for(int j = 0; j <= log; j++) {
        long c = 1 << j;
        TreeSet<Segment> cur = trees[j];
        Segment left = cur.floor(t);
        Segment right = cur.higher(t);
        if(left == null)
          left = new Segment(-1, 0);
        if(right == null)
          right = new Segment(-1, 0);
        if((v & c) == c) {
          if(left.x + left.c > p) continue;
          if(left.x + left.c == p && right.x - 1 == p) {
            s[j] -= ((left.c * (left.c + 1)) / 2 + (right.c * (right.c + 1))/ 2) * c;
            s[j] += (((left.c + right.c + 1) * (left.c + right.c + 2)) / 2) * c;
            cur.remove(left); cur.remove(right);
            cur.add(new Segment(left.x, left.c + right.c + 1));
            continue;
          }

          if(left.x + left.c == p) {
            s[j] += (left.c + 1) * c;
            left.c++;
            continue;
          }
          
          if(right.x - 1 == p) {
            s[j] += (right.c + 1) * c;
            cur.remove(right);
            right.x--;
            right.c++;
            cur.add(right);
            continue;
          }
          s[j] += c;
          cur.add(new Segment(p, 1));
        } else {
          if(left.x + left.c > p) {
            s[j] -= ((left.c * (left.c + 1)) / 2) * c;
            s[j] += (((p - left.x) * (p - left.x + 1)) / 2) * c;
            s[j] += (((left.x + left.c - 1 - p) * (left.x + left.c - p)) / 2) * c;
            cur.remove(left);
            cur.add(new Segment(left.x, p - left.x));
            if(left.x + left.c - 1 - p > 0) {
              cur.add(new Segment(p + 1, left.x + left.c - 1 - p));
            }
          }
        }
      }
      long res = 0;
      for(int j = 0; j <= log; j++) {
        res += s[j];
      }
      out.println(res);
    }
  }
}