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 Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    class GraphBuilder {
        int n, m;
        int[] x, y;
        int index;
        int[] size;


        GraphBuilder(int n, int m) {
            this.n = n;
            this.m = m;
            x = new int[m];
            y = new int[m];
            size = new int[n];
        }

        void add(int u, int v) {
            x[index] = u;
            y[index] = v;
            size[u]++;
            size[v]++;
            index++;
        }

        int[][] build() {
            int[][] graph = new int[n][];
            for (int i = 0; i < n; i++) {
                graph[i] = new int[size[i]];
            }
            for (int i = index - 1; i >= 0; i--) {
                int u = x[i];
                int v = y[i];
                graph[u][--size[u]] = v;
                graph[v][--size[v]] = u;
            }
            return graph;
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long[] readLongArray(int size) throws IOException {
        long[] res = new long[size];
        for (int i = 0; i < size; i++) {
            res[i] = readLong();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        // new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int lcm(int x, int y) {
        return x * y / gcd(x, y);
    }

    int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    }


    int DEPTH = 17;

    boolean has(int mask, int bit) {
        return (mask & (1 << bit)) != 0;
    }

    long answer(int len) {
        if (len < 0) return 0;
        return (1L + len) * len / 2;
    }

    long answer(int l, int r) {
        return answer(r - l - 1);
    }

    void solve() throws IOException {
        int n = readInt();
        int m = readInt();

        FenwickKth[] zeroes = new FenwickKth[DEPTH];
        for (int i = 0; i < DEPTH; i++) {
            zeroes[i] = new FenwickKth(n + 2);
            zeroes[i].add(-1);
            zeroes[i].add(n);
        }
        int[] a = readIntArray(n);
        long sum = 0;
        for (int d = 0; d < DEPTH; d++) {
            int prev = -1;
            long mn = 0;
            for (int i = 0; i < a.length; i++) {
                if (!has(a[i], d)) {
                    zeroes[d].add(i);
                    mn += answer(prev, i);
                    prev = i;
                }
            }
            mn += answer(prev, n);
            sum += mn * (1L << d);
        }
        for (int i = 0; i < m; i++) {
            int index = readInt() - 1;
            int nval = readInt();
            for (int bit = 0; bit < DEPTH; bit++) {
                if (has(a[index], bit) == has(nval, bit)) continue;
                long difference;
                if (has(a[index], bit)) {
                    int leftZero = zeroes[bit].lower(index, 0) - 1;
                    int rightZero = zeroes[bit].higher(index) - 1;
                    difference = -answer(leftZero, rightZero) + answer(leftZero, index) + answer(index, rightZero);
                    zeroes[bit].add(index);
                } else {
                    int leftZero = zeroes[bit].lower(index, 1) - 1;
                    int rightZero = zeroes[bit].higher(index) - 1;
                    difference = answer(leftZero, rightZero) - answer(leftZero, index) - answer(index, rightZero);
                    zeroes[bit].remove(index);
                }
                sum += difference * (1L << bit);
            }
            a[index] = nval;
            out.println(sum);
        }
    }

    class FenwickKth {
        int[] a;

        public FenwickKth(int n) {
            a = new int[Integer.highestOneBit(n) << 1];
        }

        public void add(int x, int y) {
            for (int i = x; i < a.length; i |= i + 1) {
                a[i] += y;
            }
        }

        public void add(int index) {
            add(index + 1, 1);
        }

        public void remove(int index) {
            add(index + 1, -1);
        }

        public int getSum(int x) {
            if (x >= a.length) x = a.length - 1;
            int ret = 0;
            for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
                ret += a[i];
            }
            return ret;
        }

        int lower(int index, int direct) {
            int sum = getSum(0, index + 1);
            sum -= direct;
            return getKth(sum);
        }

        int higher(int index) {
            int sum = getSum(0, index + 1);
            return getKth(sum + 1);
        }

        public int getSum(int l, int r) {
            return getSum(r) - getSum(l - 1);
        }

        public int getKth(int k) {
            int l = 0;
            int r = a.length;
            while (l < r - 1) {
                int mid = l + r >> 1;
                if (a[mid - 1] >= k) {
                    r = mid;
                } else {
                    k -= a[mid - 1];
                    l = mid;
                }
            }
            return l;
        }

    }

}