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>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const long long int inf = 9e18;
const long double pi = 2 * acos(0.0);
const int N = 1000005;
long long int tes, n, q;
vector<long long int> sieve(N, 0);
void si() {
  sieve[1] = 1;
  for (int i = 2; i < N; i++) {
    if (sieve[i] == 0) {
      for (int j = i; j < N; j += i) {
        sieve[j] = i;
      }
    }
  }
}
long long int power(long long int x, long long int y) {
  long long int res = 1ll;
  while (y > 0) {
    if (y & 1) res = res * x;
    y >>= 1;
    x = x * x;
  }
  return res;
}
struct node {
  long long int val = 0;
  node() : val(0){};
};
struct SegTree {
  long long int N;
  vector<node> st;
  vector<bool> cLazy;
  vector<long long int> lazy;
  void init(long long int n) {
    N = n;
    st.resize(4 * N + 5);
    cLazy.assign(4 * N + 5, false);
    lazy.assign(4 * N + 5, 0);
  }
  void merge(node &cur, node &l, node &r) { cur.val = l.val + r.val; }
  void propagate(long long int ver, long long int L, long long int R) {
    if (L != R) {
      cLazy[ver * 2] = cLazy[ver * 2 + 1] = 1;
      lazy[ver * 2] += lazy[ver], lazy[ver * 2 + 1] += lazy[ver];
    }
    st[ver].val += lazy[ver];
    cLazy[ver] = lazy[ver] = 0;
  }
  void build(long long int ver, long long int L, long long int R,
             vector<long long int> &a) {
    if (L == R) {
      st[ver].val = a[L - 1];
      return;
    }
    long long int M = (L + R) / 2;
    build(ver * 2, L, M, a), build(ver * 2 + 1, M + 1, R, a);
    merge(st[ver], st[ver * 2], st[ver * 2 + 1]);
  }
  node Query(long long int ver, long long int L, long long int R,
             long long int i, long long int j) {
    if (cLazy[ver]) propagate(ver, L, R);
    if (j < L || i > R) return node();
    if (i <= L && R <= j) return st[ver];
    long long int M = (L + R) / 2;
    node left = Query(ver * 2, L, M, i, j),
         right = Query(ver * 2 + 1, M + 1, R, i, j), cur;
    merge(cur, left, right);
    return cur;
  }
  node pQuery(long long int ver, long long int L, long long int R,
              long long int pos) {
    if (cLazy[ver]) propagate(ver, L, R);
    if (L == R) return st[ver];
    long long int M = (L + R) / 2;
    if (pos <= M)
      return pQuery(ver * 2, L, M, pos);
    else
      return pQuery(ver * 2 + 1, M + 1, R, pos);
  }
  void Update(long long int ver, long long int L, long long int R,
              long long int i, long long int j, long long int val) {
    if (cLazy[ver]) propagate(ver, L, R);
    if (j < L || i > R) return;
    if (i <= L && R <= j) {
      cLazy[ver] = 1, lazy[ver] += val;
      propagate(ver, L, R);
      return;
    }
    long long int M = (L + R) / 2;
    Update(ver * 2, L, M, i, j, val), Update(ver * 2 + 1, M + 1, R, i, j, val);
    merge(st[ver], st[ver * 2], st[ver * 2 + 1]);
  }
  void pUpdate(long long int ver, long long int L, long long int R,
               long long int pos, long long int val) {
    if (cLazy[ver]) propagate(ver, L, R);
    if (L == R) {
      st[ver].val += val;
      return;
    }
    long long int M = (L + R) / 2;
    if (pos <= M)
      pUpdate(ver * 2, L, M, pos, val);
    else
      pUpdate(ver * 2 + 1, M + 1, R, pos, val);
    merge(st[ver], st[ver * 2], st[ver * 2 + 1]);
  }
  node query(long long int pos) { return pQuery(1, 1, N, pos); }
  node query(long long int l, long long int r) { return Query(1, 1, N, l, r); }
  void update(long long int pos, long long int val) {
    pUpdate(1, 1, N, pos, val);
  }
  void update(long long int l, long long int r, long long int val) {
    Update(1, 1, N, l, r, val);
  }
  node sum(long long int ver, long long int L, long long int R, long long int i,
           long long int j, long long int mask, long long int lev) {
    if (j < L || i > R) return node();
    if (i <= L && R <= j) return st[ver];
    long long int M = (L + R) / 2;
    long long int chg;
    if (((mask >> lev) & 1) >= 1)
      chg = 1;
    else
      chg = 0;
    node left = sum(ver * 2 + chg, L, M, i, j, mask, lev - 1),
         right = sum(ver * 2 + 1 - chg, M + 1, R, i, j, mask, lev - 1), curr;
    merge(curr, left, right);
    return curr;
  }
};
void solve() {
  cin >> n >> q;
  long long int siz = power(2, n), mask = 0;
  vector<long long int> arr(siz);
  ;
  for (int i = 0; i < siz; i++) cin >> arr[i];
  SegTree st;
  st.init(siz);
  st.build(1, 1, siz, arr);
  ;
  for (int i = 0; i < q; i++) {
    long long int t, x, k, l, r;
    cin >> t;
    if (t == 1) {
      cin >> x >> k;
      x--;
      x ^= mask;
      st.update(x + 1, k - arr[x]);
      arr[x] = k;
    } else if (t == 2) {
      cin >> k;
      mask ^= power(2, k) - 1;
    } else if (t == 3) {
      cin >> k;
      mask ^= power(2, k);
    } else {
      cin >> l >> r;
      cout << st.sum(1, 1, siz, l, r, mask, n - 1).val << "\n";
    }
  }
}
int32_t main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  tes = 1;
  while (tes--) {
    solve();
  }
}
