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\}. 
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1401F
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int Q = Integer.parseInt(st.nextToken());
         int[] arr = new int[1<<N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < arr.length; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         SegTree segtree = new SegTree(1<<N, N);
         for(int i=0; i < arr.length; i++)
            segtree.update(i, arr[i], N);
         StringBuilder sb = new StringBuilder();
         while(Q-->0)
         {
            st = new StringTokenizer(infile.readLine());
            int tag = Integer.parseInt(st.nextToken());
            if(tag == 1)
            {
               int dex = Integer.parseInt(st.nextToken());
               int val = Integer.parseInt(st.nextToken());
               segtree.update(dex-1, val, N);
            }
            else if(tag == 2)
            {
               int K = Integer.parseInt(st.nextToken());
               for(int k=K-1; k >= 0; k--)
                  segtree.swapped[k] = !segtree.swapped[k];
            }
            else if(tag == 3)
            {
               int K = Integer.parseInt(st.nextToken());
               segtree.swapped[K] = !segtree.swapped[K];
            }
            else
            {
               int L = Integer.parseInt(st.nextToken());
               int R = Integer.parseInt(st.nextToken());
               sb.append(segtree.query(L-1, R-1, N)+"\n");
            }
         }
         System.out.print(sb);
      }
   }
   class SegTree
   {
      //definitions
      private long NULL = 0;
      //ds stuff
      public boolean[] swapped;
      private long[] tree;
      private int length;
      
      public SegTree(int N, int small)
      {
         length = N;   int b;
         for(b=0; (1<<b) < length; b++);
         tree = new long[1<<(b+1)];
         swapped = new boolean[small+1];
      }
      public long query(int left, int right, int level)
      {
         //left and right are 0-indexed
         return get(1, 0, length-1, left, right, level);  
      }
      private long get(int v, int currL, int currR, int L, int R, int level)
      {
         if(L > R)
            return NULL;
         if(L == currL && currR == R)
            return tree[v];
         int mid = (currL+currR)/2;
         int left = v*2;
         int right = v*2+1;
         if(swapped[level-1])
         {
            left++;
            right--;
         }
         return comb(get(left, currL, mid, L, Math.min(R, mid), level-1),
            get(right, mid+1, currR, Math.max(L, mid+1), R, level-1));
      }
      public void update(int dex, int delta, int level)
      {
         add(1, 0, length-1, dex, dex, delta, level);
      }
      private void add(int v, int currL, int currR, int L, int R, int delta, int level)
      {
         if(L > R)
            return;
         if(currL == L && currR == R)
         {
            //exact covering
            tree[v] = delta;
            return;
         }
         int mid = (currL+currR)/2;
         int left = v*2;
         int right = v*2+1;
         if(swapped[level-1])
         {
            left++;
            right--;
         }
         add(left, currL, mid, L, Math.min(R, mid), delta, level-1);
         add(right, mid+1, currR, Math.max(L, mid+1), R, delta, level-1);
         tree[v] = comb(tree[left], tree[right]);
      }
      private long comb(long a, long b)
      {
         return a+b;
      }
   }