#include #include using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; using mint = modint998244353; const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } template struct Matrix { array, SIZE> v; Matrix(int i = 0) { if (1 == i) { for (int i = 0; i < SIZE; ++i) { v[i][i] = 1; } } } std::array& operator[](const int i) { return v[i]; } Matrix(const array, SIZE> &s) { v = s; } Matrix operator*=(const Matrix & m) { Matrix s(0); for (int i = 0; i < SIZE; ++i) { for (int j = 0; j < SIZE; ++j) { for (int k = 0; k < SIZE; ++k) { s.v[i][j] += v[i][k] * m.v[k][j]; } } } swap(s, *this); return *this; } Matrix operator*(const Matrix other)const { return Matrix(*this) *= other; } }; Matrix op(Matrix a, Matrix b) { return b * a; } Matrix e() { return Matrix(1); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); auto unit = Matrix(); unit[0] = { 1, 0, 0 }; unit[1] = { 0, 1, 0 }; unit[2] = { 0, 0, 1 }; auto zero = Matrix(); zero[0] = { 1, 1, 0 }; zero[1] = { 0, 1, 0 }; zero[2] = { 0, 0, 1 }; auto one = Matrix(); one[0] = { 1, 0, 0 }; one[1] = { 1, 1, 1 }; one[2] = { 0, 0, 1 }; int n, q; cin >> n >> q; string s; cin >> s; vector>init(n); rep(i, n) { if ('0' == s[i])init[i] = zero; else init[i] = one; } segtree, op, e>seg(init); setst; rep(i, n)st.insert(i); while (q--) { int t, l, r; cin >> t >> l >> r; l--; if (1 == t) { auto ite = st.lower_bound(l); while (ite != st.end() && *ite < r) { seg.set(*ite, unit); ite = st.erase(ite); } } else { auto get = seg.prod(l, r); mint ans = get[0][2] + get[1][2]; cout << ans.val() << endl; } } return 0; }