#include using namespace std; using ll = long long; #define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i) #define revrep(i, t, s) for (int i = (int)(t)-1; i >= (int)(s); --i) #define all(x) begin(x), end(x) template bool chmax(T& a, const T& b) { return a < b ? (a = b, 1) : 0; } template bool chmin(T& a, const T& b) { return a > b ? (a = b, 1) : 0; } template class Modint { using mint = Modint; static_assert(m > 0, "Modulus must be positive"); public: static constexpr int mod() { return m; } constexpr Modint(long long y = 0) : x(y >= 0 ? y % m : (y % m + m) % m) {} constexpr int val() const { return x; } constexpr mint& operator+=(const mint& r) { if ((x += r.x) >= m) x -= m; return *this; } constexpr mint& operator-=(const mint& r) { if ((x += m - r.x) >= m) x -= m; return *this; } constexpr mint& operator*=(const mint& r) { x = static_cast(1LL * x * r.x % m); return *this; } constexpr mint& operator/=(const mint& r) { return *this *= r.inv(); } constexpr bool operator==(const mint& r) const { return x == r.x; } constexpr mint operator+() const { return *this; } constexpr mint operator-() const { return mint(-x); } constexpr friend mint operator+(const mint& l, const mint& r) { return mint(l) += r; } constexpr friend mint operator-(const mint& l, const mint& r) { return mint(l) -= r; } constexpr friend mint operator*(const mint& l, const mint& r) { return mint(l) *= r; } constexpr friend mint operator/(const mint& l, const mint& r) { return mint(l) /= r; } constexpr mint inv() const { int a = x, b = m, u = 1, v = 0; while (b > 0) { int t = a / b; std::swap(a -= t * b, b); std::swap(u -= t * v, v); } return mint(u); } constexpr mint pow(long long n) const { mint ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend std::ostream& operator<<(std::ostream& os, const mint& r) { return os << r.x; } friend std::istream& operator>>(std::istream& is, mint& r) { long long t; is >> t; r = mint(t); return is; } private: int x; }; template class XorSegmentTree { using T = typename M::T; public: XorSegmentTree() = default; explicit XorSegmentTree(int n) : XorSegmentTree(std::vector(n, M::id())) {} explicit XorSegmentTree(const std::vector& v) : size(std::bit_ceil(v.size())), n(std::bit_width((unsigned int)size) - 1), table(2 * size), half(1 << ((n + 1) / 2)) { for (int k = 0; k < size; ++k) { table[size + k].resize(1, k < (int)v.size() ? v[k] : M::id()); } for (int k = size - 1; k >= half; --k) pull(k); } void update(int k, const T& x) { k += size; table[k][0] = x; for (k >>= 1; k >= half; k >>= 1) pull(k); } T fold(int l, int r, int x) const { T vl = M::id(), vr = M::id(); int i = 0; for (l += size, r += size; l < r && l > 2 * half; l >>= 1, r >>= 1, ++i) { if (l & 1) { vl = M::op(vl, table[l++ ^ (x >> i)][x & ((1 << i) - 1)]); } if (r & 1) { vr = M::op(table[--r ^ (x >> i)][x & ((1 << i) - 1)], vr); } } for (int k = l; k < r; ++k) { vl = M::op(vl, table[k ^ (x >> i)][x & ((1 << i) - 1)]); } return M::op(vl, vr); } private: int size, n, half; std::vector> table; void pull(int k) { int i = n - std::bit_width((unsigned int)k) + 1; table[k].resize(1 << i); for (int x = 0; x < (1 << i); ++x) { T vl = table[2 * k][x & ~(1 << (i - 1))]; T vr = table[2 * k + 1][x & ~(1 << (i - 1))]; if (x >> (i - 1) & 1) std::swap(vl, vr); table[k][x] = M::op(vl, vr); } } }; using mint = Modint<998244353>; vector pow11, pow2; struct Monoid { using T = pair; static T id() { return {0, 0}; } static T op(T a, T b) { auto [xa, na] = a; auto [xb, nb] = b; return {xa * pow11[nb] + xb * pow2[na], na + nb}; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int n; cin >> n; string s; cin >> s; pow11.resize((1 << n) + 1, 1); pow2.resize((1 << n) + 1, 1); rep(i, 1, (1 << n) + 1) { pow11[i] = pow11[i - 1] * 11; pow2[i] = pow2[i - 1] * 2; } vector> init(1 << n); rep(i, 0, 1 << n) { init[i] = {s[i] - '0', 1}; } XorSegmentTree st(init); int q; cin >> q; while (q--) { int t; cin >> t; if (t == 1) { int x, y; cin >> x >> y; st.update(x, {y, 1}); } else { int l, r, x; cin >> l >> r >> x; ++r; cout << st.fold(l, r, x).first << "\n"; } } }