#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint998244353; struct S { mint lr, l, r, c; mint c0, s0, c1, s1; }; S op(S x, S y) { return S{ x.lr + y.lr - x.c0 * y.c1 - x.c1 * y.c0, x.l + y.l + x.c0 * y.s1 + x.c1 * y.s0, x.r + y.r + x.s0 * y.c1 + x.s1 * y.c0, x.c + y.c - x.s0 * y.s1 - x.s1 * y.s0, x.c0 + y.c0, x.s0 + y.s0, x.c1 + y.c1, x.s1 + y.s1 }; } S e() { return S{}; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; string s; cin >> s; vector init(n); rep(i, n) { init[i] = s[i] == '0' ? S{0, 0, 0, 0, 1, i, 0, 0} : S{0, 0, 0, 0, 0, 0, 1, i}; } segtree seg(init); rep(_, q) { int op; cin >> op; if (op == 1) { int i; cin >> i; i--; s[i] ^= '0' ^ '1'; seg.set(i, s[i] == '0' ? S{0, 0, 0, 0, 1, i, 0, 0} : S{0, 0, 0, 0, 0, 0, 1, i}); } else { int l, r; cin >> l >> r; l--; auto s = seg.prod(l, r); l--; mint ans = s.lr * l * r + s.l * l + s.r * r + s.c; cout << ans.val() << '\n'; } } }