#include #define forn(i, n) for(int i = 0; i < (int)(n); i++) typedef long long ll; using namespace std; const int MAXN = 100000, MOD = 1000 * 1000 * 1000 + 7; int t[4 * MAXN + 10][26], n, calc[MAXN + 1][2], color[4 * MAXN + 10], f[MAXN + 1], _f[MAXN + 1]; string s; void push(int v) { if(color[v]) { rotate(t[v * 2], t[v * 2] + (26 - color[v]), t[v * 2] + 26); rotate(t[v * 2 + 1], t[v * 2 + 1] + (26 - color[v]), t[v * 2 + 1] + 26); color[v * 2] += color[v]; color[v * 2 + 1] += color[v]; if(color[v * 2] >= 26) color[v * 2] -= 26; if(color[v * 2 + 1] >= 26) color[v * 2 + 1] -= 26; color[v] = 0; } } void build(int v = 1, int l = 0, int r = n - 1) { if(l == r) t[v][s[l] - 'a'] = 1; else { int m = (l + r) / 2; build(v * 2, l, m); build(v * 2 + 1, m + 1, r); for(int i = 0; i < 26; i++) t[v][i] = t[v * 2][i] + t[v * 2 + 1][i]; } } void upd(int l, int r, int shift, int tv = 1, int tl = 0, int tr = n - 1) { if(l > r) return; else if(l == tl && r == tr) { if(shift) rotate(t[tv], t[tv] + (26 - shift), t[tv] + 26); color[tv] += shift; if(color[tv] >= 26) color[tv] -= 26; } else { push(tv); int tm = (tl + tr) / 2; upd(l, min(tm, r), shift, tv * 2, tl, tm); upd(max(tm + 1, l), r, shift, tv * 2 + 1, tm + 1, tr); for(int i = 0; i < 26; i++) t[tv][i] = t[tv * 2][i] + t[tv * 2 + 1][i]; } } int get(int l, int r, int pos, int tv = 1, int tl = 0, int tr = n - 1) { if(l > r) return 0; else if(l == tl && r == tr) return t[tv][pos]; else { push(tv); int tm = (tl + tr) / 2; return get(l, min(tm, r), pos, tv * 2, tl, tm) + get(max(tm + 1, l), r, pos, tv * 2 + 1, tm + 1, tr); } } int main() { //ios_base::sync_with_stdio(false); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); calc[1][0] = 1; calc[1][1] = 1; for(int i = 2; i <= MAXN; i++) { calc[i][0] = (calc[i - 1][0] + calc[i - 1][1]) % MOD; calc[i][1] = (calc[i - 1][0] + calc[i - 1][1]) % MOD; } int q; scanf("%d%d", &n, &q); cin >> s; build(); for(int i = 0; i < q; i++) { int type; scanf("%d", &type); if(type == 1) { int l, r, shift; scanf("%d%d%d", &l, &r, &shift); shift %= 26; upd(l, r, shift); } else { int l, r; scanf("%d%d", &l, &r); vector cnt(26, 1), pr(26), sf(26); for(int i = 0; i < 26; i++) { cnt[i] = get(l, r, i); pr[i] = max(1, calc[cnt[i]][0]); if(i) pr[i] = (1LL * pr[i - 1] * pr[i]) % MOD; } for(int i = 25; i >= 0; i--) { sf[i] = max(1, calc[cnt[i]][0]); if(i < 25) sf[i] = (1LL * sf[i] * sf[i + 1]) % MOD; } int ans = pr[25]; for(int i = 0; i < 26; i++) { int cur = calc[cnt[i]][1]; if(i) cur = (1LL * cur * pr[i - 1]) % MOD; if(i < 25) cur = (1LL * cur * sf[i + 1]) % MOD; ans += cur; if(ans >= MOD) ans -= MOD; } printf("%d\n", ans - 1); } } return 0; }