#include using namespace std; typedef long long Long; const int mod = 1e9 + 7; Long modpow(int base, int power) { if(power == 0) return 1; if(power & 1) return (modpow(base, power - 1) * base) % mod; Long m = modpow(base, power >> 1); return (m * m) % mod; } struct alpha { int a[26]; alpha () { memset(a, 0, sizeof a); } void clear() { memset(a, 0, sizeof a); } void add(alpha &x) { for(int i = 0; i < 26; i++) { a[i] += x.a[i]; } } void shift(int val) { val %= 26; int aux[26]; memset(aux, 0, sizeof aux); for(int i = 0; i < 26; i++) { aux[(i + val) % 26] = a[i]; } for(int i = 0; i < 26; i++) { a[i] = aux[i]; } } } t[100010 * 4]; int p[100010 * 4]; int n; string s; void build(int c = 1, int b = 0, int e = n) { if(b == e) { t[c].a[s[b] - 'a'] += 1; return ; } int m = (b + e) >> 1; int l = c << 1; int r = l + 1; build(l, b, m); build(r, m+1, e); t[c].add(t[l]); t[c].add(t[r]); } void propagate(int c) { if(p[c] == 0) return ; int l = c << 1; int r = l + 1; t[l].shift(p[c]); t[r].shift(p[c]); p[l] += p[c]; p[r] += p[c]; p[c] = 0; } void update(int x, int y, int val, int c = 1, int b = 0, int e = n) { if(x <= b and e <= y) { t[c].shift(val); p[c] += val; return ; } if(y < b or e < x) return ; propagate(c); int m = (b + e) >> 1; int l = c << 1; int r = l + 1; update(x, y, val, l, b, m); update(x, y, val, r, m+1, e); t[c].clear(); t[c].add(t[l]); t[c].add(t[r]); } void query(int x, int y, alpha &ans, int c = 1, int b = 0, int e = n) { if(x <= b and e <= y) { ans.add(t[c]); return ; } if(y < b or e < x) return ; propagate(c); int m = (b + e) >> 1; int l = c << 1; int r = l + 1; query(x, y, ans, l, b, m); query(x, y, ans, r, m+1, e); return ; } Long count(int l, int r) { alpha arr; query(l, r, arr); int c[26]; for(int i = 0; i < 26; i++) { c[i] = arr.a[i]; } Long ans = 1; int cnt = 0; for(int i = 0; i < 26; i++) { if(c[i] == 0) continue; ans *= modpow(2, c[i] - 1); ans %= mod; ++cnt; // cout << char(i+'a') << " -> " << c[i] << endl; } ans += cnt * ans; ans %= mod; ans -= 1; if(ans < 0) ans += mod; return ans; } #define endl '\n' int main(int argc, char const *argv[]) { ios_base :: sync_with_stdio (false); cin.tie (0); int q; cin >> n >> q; n--; cin >> s; build(); while(q--) { int c, l, r, val; cin >> c >> l >> r; if(c == 1) { cin >> val; val %= 26; update(l, r, val); } else { cout << count(l, r) << endl; } } return 0; }