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\}. 
#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
long long int myRand(long long int R) {
  long long int val = rng() % R;
  assert(val >= 0);
  return val;
}
const long double PI = atan(1.0) * 4;
const int64_t INF64 = 3e18;
const int32_t INF32 = 2e9 + 7;
const int32_t LOG = 21;
const int32_t MOD = 1e9 + 7;
using namespace std;
long long int a[(1 << 18) + 1];
long long int t[(1 << 20) + 1];
long long int N;
long long int n;
void build(long long int i, long long int tl, long long int tr) {
  if (tl == tr) {
    t[i] = a[tl];
    return;
  }
  long long int tm = (tl + tr) >> 1;
  build(2 * i, tl, tm);
  build(2 * i + 1, tm + 1, tr);
  t[i] = t[2 * i] + t[2 * i + 1];
}
void update(long long int v, long long int tl, long long int tr,
            long long int pos, long long int new_val) {
  if (tl == tr) {
    t[v] = new_val;
  } else {
    long long int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, new_val);
    else
      update(v * 2 + 1, tm + 1, tr, pos, new_val);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long int sum(long long int v, long long int tl, long long int tr,
                  long long int l, long long int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) {
    return t[v];
  }
  long long int tm = (tl + tr) / 2;
  return sum(v * 2, tl, tm, l, min(r, tm)) +
         sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
long long int solve(long long int v, long long int tl, long long int tr,
                    long long int l, long long int r, long long int x) {
  if (l > r) return 0;
  if (l == tl && r == tr) {
    long long int len = r - l + 1;
    long long int temp = x ^ l;
    long long int start_index = (temp - (temp % len));
    return sum(1, 0, N - 1, start_index, start_index + len - 1);
  }
  long long int tm = (tl + tr) / 2;
  return solve(v * 2, tl, tm, l, min(r, tm), x) +
         solve(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  long long int tests = 1;
  for (long long int ii = 0; ii < (long long int)tests; ii++) {
    long long int q;
    cin >> n >> q;
    N = (1 << n);
    for (long long int i = 0; i < (long long int)N; i++) cin >> a[i];
    build(1, 0, N - 1);
    long long int x = 0;
    for (long long int i = 0; i < (long long int)q; i++) {
      long long int type;
      cin >> type;
      if (type == 1) {
        long long int pos, new_val;
        cin >> pos >> new_val;
        pos--;
        pos ^= x;
        update(1, 0, N - 1, pos, new_val);
      } else if (type == 2) {
        long long int k;
        cin >> k;
        x ^= ((1 << k) - 1);
      } else if (type == 3) {
        long long int k;
        cin >> k;
        x ^= (1 << k);
      } else {
        long long int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << solve(1, 0, N - 1, l, r, x) << '\n';
      }
    }
  }
  return 0;
}
