You are given an array a of length 2^n. You should process q queries on it. Each query has one of the following 4 types: 

  1. Replace(x, k) — change a_x to k; 
  2. Reverse(k) — reverse each subarray [(i-1) ⋅ 2^k+1, i ⋅ 2^k] for all i (i ≥ 1); 
  3. Swap(k) — swap subarrays [(2i-2) ⋅ 2^k+1, (2i-1) ⋅ 2^k] and [(2i-1) ⋅ 2^k+1, 2i ⋅ 2^k] for all i (i ≥ 1); 
  4. Sum(l, r) — print the sum of the elements of subarray [l, r]. 



Write a program that can quickly process given queries.

Input

The first line contains two integers n, q (0 ≤ n ≤ 18; 1 ≤ q ≤ 10^5) — the length of array a and the number of queries.

The second line contains 2^n integers a_1, a_2, …, a_{2^n} (0 ≤ a_i ≤ 10^9).

Next q lines contains queries — one per line. Each query has one of 4 types: 

  * "1 x k" (1 ≤ x ≤ 2^n; 0 ≤ k ≤ 10^9) — Replace(x, k); 
  * "2 k" (0 ≤ k ≤ n) — Reverse(k); 
  * "3 k" (0 ≤ k < n) — Swap(k); 
  * "4 l r" (1 ≤ l ≤ r ≤ 2^n) — Sum(l, r). 



It is guaranteed that there is at least one Sum query.

Output

Print the answer for each Sum query.

Examples

Input


2 3
7 4 9 9
1 2 8
3 1
4 2 4


Output


24


Input


3 8
7 0 8 8 7 1 5 2
4 3 7
2 1
3 2
4 1 6
2 3
1 5 16
4 8 8
3 0


Output


29
22
1

Note

In the first sample, initially, the array a is equal to \{7,4,9,9\}.

After processing the first query. the array a becomes \{7,8,9,9\}.

After processing the second query, the array a_i becomes \{9,9,7,8\}

Therefore, the answer to the third query is 9+7+8=24.

In the second sample, initially, the array a is equal to \{7,0,8,8,7,1,5,2\}. What happens next is: 

  1. Sum(3, 7) → 8 + 8 + 7 + 1 + 5 = 29; 
  2. Reverse(1) → \{0,7,8,8,1,7,2,5\}; 
  3. Swap(2) → \{1,7,2,5,0,7,8,8\}; 
  4. Sum(1, 6) → 1 + 7 + 2 + 5 + 0 + 7 = 22; 
  5. Reverse(3) → \{8,8,7,0,5,2,7,1\}; 
  6. Replace(5, 16) → \{8,8,7,0,16,2,7,1\}; 
  7. Sum(8, 8) → 1; 
  8. Swap(0) → \{8,8,0,7,2,16,1,7\}. 
/**
 * author: derrick20
 * created: 8/24/20 2:41 AM
 */
import java.io.*;
import java.util.*;

public class ReverseAndSwapInverse implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ReverseAndSwapInverse(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        swap = new boolean[N + 1];
        long[] init = sc.nextLongs(1 << N);
        SegmentTree st = new SegmentTree(init);
//        System.out.println(Arrays.toString(st.sum));
        while (Q-->0) {
            int type = sc.nextInt();
            if (type == 1) {
                int i = sc.nextInt() - 1;
                int v = sc.nextInt();
                st.update(1, i, v, N);
            } else if (type == 2) {
                int k = sc.nextInt();
                for (int lvl = k - 1; lvl >= 0; lvl--) {
                    swap[lvl] = !swap[lvl];
                }
            } else if (type == 3) {
                int k = sc.nextInt();
                swap[k] = !swap[k];
            } else {
                int l = sc.nextInt() - 1;
                int r = sc.nextInt() - 1;
                out.println(st.query(1, l, r, N));
            }
//            StringBuilder line = new StringBuilder();
//            for (int i = 0; i < 1 << N; i++) {
//                line.append(st.query(1, i, i, N)).append(" ");
//            }
//            System.out.println(line);
        }
        out.close();
    }

    static boolean[] swap;

    static class SegmentTree {
        long[] sum, init;
        int[] lo, hi;
        int N;
        public SegmentTree(long[] init) {
            // each additional node contributes 2, base case is 1
            // so 2n-1 total nodes. Add 1 for 1-index
            N = init.length;
            lo = new int[4 * N + 1];
            hi = new int[4 * N + 1];
            sum = new long[4 * N + 1];
            this.init = init;
            buildTree(1, 0, N - 1);
        }

        public void buildTree(int node, int l, int r) {
            if (l == r) {
                lo[node] = hi[node] = l;
                sum[node] = init[l];
            } else {
                int mid = (l + r) / 2;
                lo[node] = l;
                hi[node] = r;
                buildTree(2 * node, l, mid);
                buildTree(2 * node + 1, mid + 1, r);
                sum[node] = sum[2 * node] + sum[2 * node + 1];
            }
        }

        public void update(int node, int i, int val, int level) {
            if (lo[node] == i && i == hi[node]) {
                sum[node] = val;
            } else if (i < lo[node] || hi[node] < i) {
                return;
            } else {
                if (swap[level - 1]) {
                    int shift = 1 << (level - 1);
                    if (i < lo[node] + shift) {
                        i += shift;
                    } else {
                        i -= shift;
                    }
                }
                update(2 * node, i, val, level - 1);
                update(2 * node + 1, i, val, level - 1);
                sum[node] = sum[2 * node] + sum[2 * node + 1];
            }
        }

        public long query(int node, int l, int r, int level) {
            if (l <= lo[node] && hi[node] <= r) {
                return sum[node];
            } else if (r < lo[node] || hi[node] < l) {
                return 0;
            } else {
                if (!swap[level - 1]) {
                    long left = query(2 * node, l, r, level - 1);
                    long right = query(2 * node + 1, l, r, level - 1);
                    return left + right;
                } else {
//                    System.out.print("Full = " + lo[node] + " " + hi[node] + ": ");
//                    System.out.print(l + " " + r + " becomes -> ");
                    r = Math.min(r, hi[node]);
                    l = Math.max(l, lo[node]);
                    int dl = l - lo[node];
                    int dr = r - lo[node];
                    int full = 1 << level;
                    int half = 1 << (level - 1);
                    dl = (dl + half) % full;
                    dr = (dr + half) % full;
                    l = lo[node] + dl;
                    r = lo[node] + dr;
//                    System.out.print(l + " " + r + "\n");
                    if (l > r) {
                        long left = query(2 * node, lo[node], r, level - 1);
                        long right = query(2 * node + 1, l, hi[node], level - 1);
                        return left + right;
                    } else {
                        long left = query(2 * node, l, r, level - 1);
                        long right = query(2 * node + 1, l, r, level - 1);
                        return left + right;
                    }
                }
            }
        }
    }

    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }
    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }
    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}