#include #include #include #include using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define TRACE(x) cout << #x << " = " << x << endl #define _ << " _ " << typedef long long llint; const int MAX = 100100; const int off = 1<<17; const int mod = 1e9 + 7; inline int add(int a, int b) { return a+b >= mod ? a+b-mod : a+b; } inline int sub(int a, int b) { return a >= b ? a-b : a-b+mod; } inline int mul(int a, int b) { return llint(a)*b % mod; } vector T[2*off]; int S[2*off]; void sh(int i, int x) { S[i] = (S[i] + x) % 26; rotate(T[i].begin(), T[i].begin() + ((26-x) % 26), T[i].end()); } void propagate(int i) { if (S[i]) { sh(i*2, S[i]); sh(i*2+1, S[i]); S[i] = 0; } } vector merge(const vector& a, const vector& b) { vector c(26); REP(i, 26) c[i] = a[i] + b[i]; return c; } void shift(int i, int lo, int hi, int a, int b, int k) { if (lo >= b || hi <= a) return; if (lo >= a && hi <= b) { sh(i, k); return; } propagate(i); shift(i*2, lo, (lo+hi)/2, a, b, k); shift(i*2+1, (lo+hi)/2, hi, a, b, k); T[i] = merge(T[i*2], T[i*2+1]); } vector count(int i, int lo, int hi, int a, int b) { if (lo >= b || hi <= a) return vector(26, 0); if (lo >= a && hi <= b) return T[i]; propagate(i); return merge(count(i*2, lo, (lo+hi)/2, a, b), count(i*2+1, (lo+hi)/2, hi, a, b)); } char s[MAX]; int pw[MAX]; int main(void) { pw[0] = 1; FOR(i, 1, MAX) pw[i] = mul(pw[i-1], 2); int n, q; scanf("%d %d", &n, &q); scanf("%s", s); REP(i, 2*off) T[i].resize(26); REP(i, n) T[off+i][s[i]-'a']++; for (int i = off-1; i >= 0; --i) REP(j, 26) T[i][j] = T[2*i][j] + T[2*i+1][j]; REP(i, q) { int tip; scanf("%d", &tip); if (tip == 1) { int a, b, t; scanf("%d %d %d", &a, &b, &t); t %= 26; shift(1, 0, off, a, b+1, t); } if (tip == 2) { int a, b; scanf("%d %d", &a, &b); vector v = count(1, 0, off, a, b+1); int ans = 0; REP(j, 27) { int ways = 1; REP(k, 26) if (v[k] && k != j) ways = mul(ways, pw[v[k]-1]); if (j != 26) { if (v[j] == 0) ways = 0; else ways = mul(ways, pw[v[j]-1]); } ans = add(ans, ways); } ans = sub(ans, 1); printf("%d\n", ans); } } return 0; }