#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; } node e(){ return node(); } template struct xor_segment_tree{ int LOG, N; vector> ST; xor_segment_tree(vector &A){ N = A.size(); LOG = __builtin_ctz(N); ST = vector>(LOG + 1, vector(N)); for (int i = 0; i < N; i++){ ST[0][i] = A[i]; } for (int i = 0; i < LOG; i++){ for (int j = 0; j < N; j++){ ST[i + 1][j] = op(ST[i][j], ST[i][j ^ (1 << i)]); } } } T range_fold(int L, int R, int x){ T ansL = e(), ansR = e(); for (int i = 0; i <= LOG; i++){ if (L == R){ break; } if ((L >> i & 1) == 1){ ansL = op(ansL, ST[i][L ^ x]); L += 1 << i; } if ((R >> i & 1) == 1){ R -= 1 << i; ansR = op(ST[i][R ^ x], ansR); } } return op(ansL, ansR); } }; 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); 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; } if (pos.size() == (1 << (n / 2))){ ST = xor_segment_tree(A); pos.clear(); } } }