#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define endl "\n" #ifndef MAIN_BEGIN #define START_TIMER(...) #define TIMESTAMP(...) #define MAIN_BEGIN int main() { \ ios::sync_with_stdio(false); #define RETURN return 0 #define MAIN_END RETURN; } #define OUTPUT if(false) cout #endif int fr[400000][26]; int sh[400000]; std::string s; void build(int i, int l, int r) { if(l == r) { for(int a=0; a<26; a++) { fr[i][a] = 0; } fr[i][s[l] - 'a'] = 1; sh[i] = 0; } else { int il = i*2; int ir = i*2+1; build(il, l, (l+r)/2); build(ir, (l+r)/2+1, r); for(int a=0; a<26; a++) { fr[i][a] = fr[il][a] + fr[ir][a]; } } } int sss[26]; int fff[26]; void update(int i) { int il = i*2; int ir = i*2+1; sh[il] = (sh[il] + sh[i]) % 26; sh[ir] = (sh[ir] + sh[i]) % 26; for(int a=0; a<26; a++) { sss[(a + sh[i]) % 26] = fr[i][a]; } for(int a=0; a<26; a++) { fr[i][a] = sss[a]; } sh[i] = 0; } void shift(int i, int l, int r, int ll, int rr, int t) { if(sh[i] != 0) update(i); if(rr < l || ll > r) { return; } if(l >= ll && r <= rr) { int il = i*2; int ir = i*2+1; sh[il] = t; sh[ir] = t; for(int a=0; a<26; a++) { sss[(a + t) % 26] = fr[i][a]; } for(int a=0; a<26; a++) { fr[i][a] = sss[a]; } } else { int il = i*2; int ir = i*2+1; shift(il, l, (l+r)/2, ll, rr, t); shift(ir, (l+r)/2+1, r, ll, rr, t); for(int a=0; a<26; a++) { fr[i][a] = fr[il][a] + fr[ir][a]; } } } void count(int i, int l, int r, int ll, int rr) { if(sh[i] != 0) update(i); if(rr < l || ll > r) { return; } if(l >= ll && r <= rr) { for(int a=0; a<26; a++) { fff[a] += fr[i][a]; } } else { int il = i*2; int ir = i*2+1; count(il, l, (l+r)/2, ll, rr); count(ir, (l+r)/2+1, r, ll, rr); } } long long odd[100000]; long long even[100000]; MAIN_BEGIN int n; cin >> n; int q; cin >> q; cin >> s; even[0] = 1; even[1] = 1; even[2] = 2; odd[0] = 1; odd[1] = 1; odd[2] = 2; for(long long a=3; a<100000; a++) { even[a] = (even[a-1] * 2) % 1000000007LL; odd[a] = (odd[a-1] * 2) % 1000000007LL; } build(1, 0, n-1); for(int qq=0; qq> type; if(type == 1) { int i; int j; long long t; cin >> i >> j >> t; shift(1, 0, n-1, i, j, t % 26); } else { int i; int j; cin >> i >> j; for(int a=0; a<26; a++) { fff[a] = 0; } count(1, 0, n-1, i, j); long long result = 0LL; for(int a=0; a<26; a++) { if(fff[a] > 0) { long long add = odd[fff[a]]; for (int b = 0; b < 26; b++) { if (a != b) add = (add * even[fff[b]]) % 1000000007LL; } result = (result + add) % 1000000007LL; } } //cout << fff[0] << " / " << fff[1] << " / " << fff[2] << endl; long long add = 1LL; for(int b=0; b<26; b++) { add = (add * even[fff[b]]) % 1000000007LL; } result = (result + add) % 1000000007LL; result = (result + 1000000006) % 1000000007LL; cout << result << endl; } } MAIN_END