#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ll long long using namespace std; ll mulmod(ll a, ll b, ll mod) { ll x = 0,y = a % mod; while (b > 0) { if (b % 2 == 1) { x = (x + y) % mod; } y = (y * 2) % mod; b /= 2; } return x % mod; } /* * modular exponentiation */ ll modulo(ll base, ll exponent, ll mod) { ll x = 1; ll y = base; while (exponent > 0) { if (exponent % 2 == 1) x = (x * y) % mod; y = (y * y) % mod; exponent = exponent / 2; } return x % mod; } int main(){ int n; int q; cin >> n >> q; string s; cin >> s; long long MOD = 1000000007; long long C[5001][5001]; int i, j; // Caculate value of Binomial Coefficient in bottom up manner for (i = 0; i <= n; i++) { for (j = 0; j <= i; j++) { // Base Cases if (j == 0 || j == i) C[i][j] = 1; // Calculate value using previosly stored values else C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD; } } int brojSlova[100001][26]; for(int u = 0; u < 26; u++){ brojSlova[0][u] = 0; } for(int u = 0; u < s.size(); u++){ for(int k = 0; k < 26; k++){ brojSlova[u][k] = brojSlova[u-1][k]; } brojSlova[u][s[u]-'a']++; } for(int a0 = 0; a0 < q; a0++){ int opera; cin >> opera; if(opera == 1){ int a,b,c; cin >> a >> b >> c; c = c%26; for(int h = a; h <= b; h++){ int br[26]; for(int y = 0; y < 26; y++){ br[y] = brojSlova[h][y]-brojSlova[a-1][y]; } for(int y = 0; y < 26; y++){ brojSlova[h][y] += (br[(y+26-c)%26]-br[y]); } } }else{ int a,b; cin >> a >> b; long long br[26]; for(int y = 0; y < 26; y++){ br[y] = brojSlova[b][y]-brojSlova[a-1][y]; //cout << br[y] << " "; } int brojE = 0; for(int y = 0; y < 26; y++){ if(br[y]) brojE++; } cout << (mulmod(brojE+1,modulo(2,b-a+1-brojE,MOD),MOD)+MOD-1)%MOD << endl; } // your code goes here } return 0; }