#include #include using namespace std; using namespace atcoder; istream &operator>>(istream &is, modint &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint &a) { return os << a.val(); } istream &operator>>(istream &is, modint998244353 &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint998244353 &a) { return os << a.val(); } istream &operator>>(istream &is, modint1000000007 &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint1000000007 &a) { return os << a.val(); } typedef long long ll; typedef vector> Graph; typedef pair pii; typedef pair pll; #define FOR(i,l,r) for (int i = l;i < (int)(r); i++) #define rep(i,n) for (int i = 0;i < (int)(n); i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define my_sort(x) sort(x.begin(), x.end()) #define my_max(x) *max_element(all(x)) #define my_min(x) *min_element(all(x)) template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = (1<<30) - 1; const ll LINF = (1LL<<62) - 1; const int MOD = 998244353; const int MOD2 = 1e9+7; const double PI = acos(-1); vector di = {1,0,-1,0}; vector dj = {0,1,0,-1}; #ifdef LOCAL # include # define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define debug(...) (static_cast(0)) #endif // https://youtu.be/ylWYSurx10A?t=2352 template struct Matrix{ int h, w; vector> d; Matrix() {} Matrix(int h, int w, T val=0): h(h), w(w), d(h, vector(w,val)) {} Matrix(int n, T val=0): h(n), w(n), d(n, vector(n,val)) {} Matrix& unit(){ assert(h == w); rep(i,h) d[i][i] = 1; return *this; } const vector& operator[](int i) const { return d[i];} vector& operator[](int i) { return d[i];} Matrix operator*(const Matrix& a) const { assert(w == a.h); Matrix r(h, a.w); rep(i,h)rep(k,w)rep(j,a.w){ r[i][j] += d[i][k] * a[k][j]; } return r; } Matrix pow(long long t) const { assert(h == w); if(!t) Matrix(h, h).unit(); if(t == 1) return *this; Matrix r = pow(t >> 1); r = r * r; if(t & 1) r = r * (*this); return r; } }; const int D = 3; using mint = modint998244353; using S = Matrix; S op(S a, S b){ return a * b; } S e(){ return S(D).unit(); } int main(){ cin.tie(0); ios_base::sync_with_stdio(false); int N, Q; cin >> N >> Q; string T; cin >> T; S zero = S(D).unit(); zero[0][1] = 1; S one = S(D).unit(); one[1][0] = 1; one[1][2] = 1; S eye = S(D).unit(); vector dat(N); rep(i, N){ if(T[i] == '0') dat[N - 1 - i] = zero; if(T[i] == '1') dat[N - 1 - i] = one; } segtree seg(dat); set rest; rep(i, N) rest.insert(i); while(Q--){ int f, l, r; cin >> f >> l >> r; l--; if(f == 1){ auto itr = rest.lower_bound(l); while(itr != rest.end() && *itr < r){ seg.set(N - 1 - *itr, eye); itr = rest.erase(itr); } } else{ S res = seg.prod((N - 1) - r + 1, N - 1 - l + 1); cout << res[0][2] + res[1][2] << endl; } } }