#include #include #include #include #include #include #define pb push_back #define mp make_pair #define sz(s) ((int)(s.size())) #define all(s) s.begin(),s.end() #define rep(i,a,n) for(int i=a;i<=n;++i) #define per(i,n,a) for(int i=n;i>=a;--i) #define dbg(x) cerr << (#x) << " --> " << (x) << nxtl; #define onlycin ios_base::sync_with_stdio(false); cin.tie(0) using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef double ld; typedef tree< pair < int, int >, null_type, less< pair < int, int > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int MAXN = (int)5e5+228; const char nxtl = '\n'; const int mod = 47619049;//(int)1e9+7; const double eps = (double)1e-9; template inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;} template inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;} int n, q, pref[MAXN][30], lazy[MAXN], pw[MAXN]; string s; int binpow(int x, int y) { int res = 1; while(y) { if(y&1) res = (res*1ll*x)%mod; x = (x*1ll*x)%mod; y /= 2; } return res; } int main() { #ifdef accepted freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif onlycin; cin >> n >> q; pw[0] = 1; int inv2 = binpow(2,mod-2); rep(i,1,n) pw[i] = (pw[i-1]*2) % mod; cin >> s; vector < pair < int, pair < int, int > > > sqr; memset(pref[0],0,sizeof pref[0]); pref[0][s[0]-'a']++; rep(Q,1,n-1) { pref[Q][s[Q]-'a']++; rep(alpha,0,25) pref[Q][alpha] += pref[Q-1][alpha];} rep(i,1,q) { int type; cin >> type; if(type == 1) { int l, r, k; cin >> l >> r >> k; k %= 26; rep(Q,l,r) s[Q] = (s[Q]-'a'+k)%26+'a'; memset(pref[0],0,sizeof pref[0]); pref[0][s[0]-'a']++; rep(Q,1,n-1) { memset(pref[Q],0,sizeof pref[Q]); pref[Q][s[Q]-'a']++; rep(alpha,0,25) pref[Q][alpha] += pref[Q-1][alpha];} } else { int l, r; cin >> l >> r; int res = 1; vector < int > val(35,0); rep(alpha,0,25) { int cnt = pref[r][alpha]-(l>0 ? pref[l-1][alpha] : 0); if(!cnt) continue; res = pw[cnt]*1ll*inv2%mod*1ll*res%mod; val[alpha] = pw[cnt]*1ll*inv2%mod; // cerr << alpha << " --> " << val[alpha] << nxtl; } int cur = res; res--; if(res < 0) res += mod; rep(alpha,0,25) { int cnt = pref[r][alpha]-(l>0 ? pref[l-1][alpha] : 0); if(!cnt) continue; res += cur*1ll*binpow(val[alpha],mod-2)%mod*1ll*val[alpha]%mod; } cout << res << nxtl; } } return 0; }