#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include using namespace std; #define pass (void)0 #define INF (1<<30)-1 #define INFLL (1LL<<60)-1 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--) #define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define repr2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((int)(x).size()) #define YesNo(cond) cout << ((cond) ? "Yes\n" : "No\n") #define YESNO(cond) cout << ((cond) ? "YES\n" : "NO\n") using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vvi = vector; using vvl = vector; template void print(const T& value) { cout << value << "\n"; } template void print(const vector& vec) { for (auto& v : vec) cout << v << " "; cout << "\n"; } template void input(vector& vec) { for (auto& v : vec) cin >> v; }; template bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; } template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } #include using namespace atcoder; using mint = modint998244353; using vm = vector; using mat = array, 3>; mat unity = { array {1, 0, 0}, array {0, 1, 0}, array {0, 0, 1} }; mat zero = { array {0, 0, 0}, array {0, 0, 0}, array {0, 0, 0} }; mat operator* (mat& left, mat& right) { mat res = zero; rep (i, 3) { rep (j, 3) { rep (k, 3) { res[i][j] += left[i][k]*right[k][j]; } } } return res; } mat op(mat left, mat right) { return right*left; } mat e() { return unity; } mat mapping(bool top, mat bottom) { return top ? e() : bottom; } bool composition(bool top, bool bottom) { return top|bottom; } bool ID() { return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(10); ll N, Q; cin >> N >> Q; string S; cin >> S; vector def(N); rep (i, N) { ll n = S[i]-'0'; mat res = unity; rep (j, 3) res[j][n] = 1; def[i] = res; } lazy_segtree seg(def); while (Q--) { ll t, l, r; cin >> t >> l >> r; l --; r --; if (t == 1) { seg.apply(l, r+1, true); } else { auto res = seg.prod(l, r+1); print(res[2][1].val()); } } }