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 {
    
    static boolean get(int val, int bitIndex) {
        return (val & (1 << bitIndex)) != 0;
    }
    
    public static void main(String[] args) throws Exception {
        FastScanner scan = new FastScanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; ++i) {
            values[i] = scan.nextInt();
        }
        int[] arrP = new int[m];
        int[] arrV = new int[m];
        for (int i = 0; i < m; ++i) {
            arrP[i] = scan.nextInt() - 1;
            arrV[i] = scan.nextInt();
        }
        
        StringBuilder builder = new StringBuilder(m * 10);
        int bitNum = 17;
        int[][] left = new int[bitNum][n];
        for (int i = 0; i < n; ++i) {
            int val = values[i];
            for (int j = 0; j < bitNum; ++j) {
                if (get(val, j)) {
                    if (i > 0 && left[j][i - 1] >= 0) {
                        left[j][i] = left[j][i - 1];
                    } else {
                        left[j][i] = i;
                    }
                } else {
                    left[j][i] = -1;
                }
            }
        }
        ArrayList<TreeMap<Integer, Integer>> treeList = new ArrayList<TreeMap<Integer, Integer>>();
        long res = 0;
        for (int index = 0; index < bitNum; ++index) {
            TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
            treeList.add(map);
            for (int i = n - 1; i >= 0; --i) {
                if (left[index][i] == -1) {
                    continue;
                }
                int next = left[index][i];
                map.put(next, i);
                int len = i - next + 1;
                res += cal(len, index);
                i = next;
            }
        }
        for (int task = 0; task < m; ++task) {
            int p = arrP[task];
            int v = arrV[task];
            for (int index = 0; index < bitNum; ++index) {
                TreeMap<Integer, Integer> map = treeList.get(index);
                Integer leftKey = map.floorKey(p);
                Integer rightKey = map.ceilingKey(p);
                if (get(v, index)) {
                    if (leftKey != null && map.get(leftKey) >= p) {
                        continue;
                    } else {
                        Integer from = p, to = p;
                        int leftLen = 0, rightLen = 0;
                        if (leftKey != null && map.get(leftKey) + 1 == p) {
                            leftLen = map.get(leftKey) - leftKey + 1;
                            from = leftKey;
                        }
                        if (rightKey != null && rightKey == p + 1) {
                            rightLen = map.get(rightKey) - rightKey + 1;
                            to = map.remove(rightKey);
                        }
                        map.put(from, to);
                        res += cal(leftLen + rightLen + 1, index) - cal(leftLen, index) - cal(rightLen, index);
                    }
                } else {
                    if (leftKey == null || map.get(leftKey) < p) {
                        continue;
                    } else {
                        int end = map.get(leftKey);
                        int leftLen = p - leftKey;
                        int rightLen = end - p;
                        if (p != leftKey) {
                            map.put(leftKey, p - 1);
                        } else {
                            map.remove(leftKey);
                        }
                        if (p != end) {
                            map.put(p + 1, end);
                        }
                        res += cal(leftLen, index) + cal(rightLen, index) - cal(leftLen + rightLen + 1, index);
                    }
                }
            }
            builder.append(Long.toString(res));
            builder.append('\n');
        }
        System.out.print(builder.toString());
        System.out.flush();
    }
    
    private static long cal(int len, int index) {
        if (len == 0) {
            return 0;
        }
        long base = 1 << index;
        return base * len * (len + 1) / 2;
    }
}

class FastScanner {
    BufferedReader in;
    StringTokenizer tok;

    public FastScanner(InputStream in) {
        this.in = new BufferedReader(new InputStreamReader(in));
        tok = new StringTokenizer("");
    }

    private String tryReadNextLine() {
        try {
            return in.readLine();
        } catch (Exception e) {
            throw new InputMismatchException();
        }
    }

    public String nextToken() {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(next());
        }
        return tok.nextToken();
    }

    public String next() {
        String newLine = tryReadNextLine();
        if (newLine == null)
            throw new InputMismatchException();
        return newLine;
    }

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

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

}