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\}. 
// package CodeForces;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

public class Round665F {

	public static class node {
		long sum;
		int level;
		node l, r;
		
		public node(long sum, int level) {
			this.sum = sum;
			this.level = level;
		}
	}
	
	public static node Build(long[] arr, int level, int start, int end) {
		if(start == end) {
			return new node(arr[start], level);
		}
		int mid = (start + end)>>1;
		node left = Build(arr, level - 1, start, mid);
		node right = Build(arr, level - 1, mid + 1, end);
		node now = new node(left.sum + right.sum, level);
		now.l = left;
		now.r = right;
		return now;
	}
	
	public static int[] swaps;
	public static int[] reverse;
	
	public static void Update(node curr, int level, long idx, long new_val) {
		if(level == 0) {
			curr.sum = new_val;
			return;
		}
		int mid = 1<<(level - 1);
		boolean dir;
		if(idx < mid) {
			dir = true;
		}else {
			idx -= mid;
			dir = false;
		}
		boolean my_LR_reversal = false;
		if(swaps[level] == 1) {
			my_LR_reversal ^= true;
		}
		if(reverse[level] == 1) {
			idx = mid - 1 - idx;
			my_LR_reversal ^= true;
		}
		if(my_LR_reversal){
			if(dir) {
				Update(curr.r, level - 1, idx, new_val);
			}else {
				Update(curr.l, level - 1, idx, new_val);
			}
		}else {
			if(dir) {
				Update(curr.l, level - 1, idx, new_val);
			}else {
				Update(curr.r, level - 1, idx, new_val);
			}
		}
		curr.sum = curr.l.sum + curr.r.sum;
	}
	
	public static long Query(node curr, int level, int idx, boolean LR_reverse) {
		if(level == 0) {
			return curr.sum;
		}
		int mid = 1<<(level - 1);
		boolean my_LR_reversal = LR_reverse;
		if(swaps[level] == 1) {
			if(idx >= mid) {
				idx -= mid;
			}else {
				idx += mid;
			}
			my_LR_reversal ^= true;
		}
		if(reverse[level] == 1) {
			LR_reverse ^= true;
			idx = mid * 2 - 1 - idx;
			my_LR_reversal ^= true;
		}
		if(my_LR_reversal) {
			if(idx >= mid) {
				return Query(curr.r, level - 1, idx - mid, LR_reverse);
			}else {
				return curr.r.sum + Query(curr.l, level - 1, idx, LR_reverse);
			}
		}else {
			if(idx >= mid) {
				return curr.l.sum + Query(curr.r, level - 1, idx - mid, LR_reverse);
			}else {
				return Query(curr.l, level - 1, idx, LR_reverse);
			}
		}
	}
	
	public static void solve() {
		int n = s.nextInt();
		int q = s.nextInt();
		long[] arr = new long[1<<n];
		for(int i = 0; i < (1<<n); i++) {
			arr[i] = s.nextLong();
		}
		swaps = new int[n + 1];
		reverse = new int[n + 1];
		node root = Build(arr, n, 0, (1<<n) - 1);
		while(q-- > 0) {
			int type = s.nextInt();
			if(type == 1) {
				int idx = s.nextInt() - 1;
				long k = s.nextLong();
				Update(root, n, idx, k);
			}else if(type == 2) {
				int k = s.nextInt();
				reverse[k]++;
				reverse[k] %= 2;
			}else if(type == 3) {
				int k = s.nextInt();
				swaps[k + 1]++;
				swaps[k + 1] %= 2;
			}else {
				int l = s.nextInt() - 1;
				int r = s.nextInt() - 1;
				long ans = Query(root, n, r, false) - (l == 0 ? 0 : Query(root, n, l - 1, false));
				out.println(ans);
			}
		}
	}

	public static void main(String[] args) {
		new Thread(null, null, "Thread", 1 << 27) {
			public void run() {
				try {
					out = new PrintWriter(new BufferedOutputStream(System.out));
					s = new FastReader(System.in);
					solve();
					out.close();
				} catch (Exception e) {
					e.printStackTrace();
					System.exit(1);
				}
			}
		}.start();
	}

	public static PrintWriter out;
	public static FastReader s;

	public static class FastReader {

		private InputStream stream;
		private byte[] buf = new byte[4096];
		private int curChar, snumChars;

		public FastReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (snumChars == -1) {
				throw new InputMismatchException();
			}
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException E) {
					throw new InputMismatchException();
				}
			}
			if (snumChars <= 0) {
				return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int number = 0;
			do {
				number *= 10;
				number += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long number = 0;
			do {
				number *= 10L;
				number += (long) (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextLong();
			}
			return arr;
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndofLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndofLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	
}
