#include using namespace std; const long long MOD = 998244353; struct node{ long long x, p2, p11; node(): x(0), p2(1), p11(1){ } node(int x): x(x), p2(2), p11(11){ } }; node op(node L, node R){ node ans; ans.x = (L.x * R.p11 + L.p2 * R.x) % MOD; ans.p2 = L.p2 * R.p2 % MOD; ans.p11 = L.p11 * R.p11 % MOD; return ans; } template struct xor_segment_tree{ int N; vector> ST; function f; T E; xor_segment_tree(vector &A, function f, T E): f(f), E(E){ N = A.size(); ST = vector>(N * 2 - 1); for (int i = 0; i < N; i++){ ST[N - 1 + i].push_back(A[i]); } for (int i = N - 2; i >= 0; i--){ int cnt = ST[i * 2 + 1].size(); for (int j = 0; j < cnt; j++){ ST[i].push_back(f(ST[i * 2 + 1][j], ST[i * 2 + 2][j])); } for (int j = 0; j < cnt; j++){ ST[i].push_back(f(ST[i * 2 + 2][j], ST[i * 2 + 1][j])); } } } T range_fold(int L, int R, int x, int i, int l, int r){ if (r <= L || R <= l){ return E; } else if (L <= l && r <= R){ return ST[i][x]; } else { int p = (r - l) / 2; int m = (l + r) / 2; if ((x & p) == 0){ T resL = range_fold(L, R, x, i * 2 + 1, l, m); T resR = range_fold(L, R, x, i * 2 + 2, m, r); return f(resL, resR); } else { T resL = E; if (R >= m){ resL = range_fold(max(L, m) - p, R - p, x ^ p, i * 2 + 1, l, m); } T resR = E; if (L < m){ resR = range_fold(L + p, min(R, m) + p, x ^ p, i * 2 + 2, m, r); } return f(resR, resL); } } } T range_fold(int L, int R, int x){ return range_fold(L, R, x, 0, 0, N); } }; int main(){ int n; cin >> n; string S; cin >> S; vector A(1 << n); for (int i = 0; i < (1 << n); i++){ A[i] = node(S[i] - '0'); } int Q; cin >> Q; vector pos; xor_segment_tree ST(A, op, node()); for (int i = 0; i < Q; i++){ int t; cin >> t; if (t == 1){ int x, y; cin >> x >> y; A[x] = node(y); pos.push_back(x); } if (t == 2){ int L, R, X; cin >> L >> R >> X; R++; vector pos2 = {L - 1, R}; for (int j : pos){ if (L <= (j ^ X) && (j ^ X) < R){ pos2.push_back(j ^ X); } } sort(pos2.begin(), pos2.end()); pos2.erase(unique(pos2.begin(), pos2.end()), pos2.end()); int cnt2 = pos2.size() - 1; node ans; for (int j = 0; j < cnt2; j++){ ans = op(ans, ST.range_fold(pos2[j] + 1, pos2[j + 1], X)); if (j < cnt2 - 1){ ans = op(ans, A[pos2[j + 1] ^ X]); } } cout << ans.x << endl; } } }