#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int Maxb = 26; const int Maxn = 100005; const int Maxm = 524288; const int mod = 1000000007; int pw[Maxn]; int n, q; string s; int st[Maxm], fl[Maxm]; int Shuffle(int mask, int by) { by %= Maxb; int tk = mask & ((1 << Maxb - by) - 1); mask >>= Maxb - by; mask |= tk << by; return mask; } void downOn(int v, int by) { st[v] = Shuffle(st[v], by); fl[v] = (fl[v] + by) % Maxb; } void Down(int v) { if (fl[v]) { downOn(2 * v, fl[v]); downOn(2 * v + 1, fl[v]); fl[v] = 0; } } void Union(int v) { st[v] = (st[2 * v] | st[2 * v + 1]); } void Create(int v, int l, int r) { if (l == r) st[v] = 1 << (s[l] - 'a'); else { int m = l + r >> 1; Create(2 * v, l, m); Create(2 * v + 1, m + 1, r); Union(v); } } void Update(int v, int l, int r, int a, int b, int val) { if (l == a && r == b) downOn(v, val); else { Down(v); int m = l + r >> 1; if (a <= m) Update(2 * v, l, m, a, min(m, b), val); if (m + 1 <= b) Update(2 * v + 1, m + 1, r, max(m + 1, a), b, val); Union(v); } } int getMask(int v, int l, int r, int a, int b) { if (l == a && r == b) return st[v]; else { Down(v); int m = l + r >> 1; if (b <= m) return getMask(2 * v, l, m, a, b); if (m + 1 <= a) return getMask(2 * v + 1, m + 1, r, a, b); return (getMask(2 * v, l, m, a, m) | getMask(2 * v + 1, m + 1, r, m + 1, b)); } } int main(){ pw[0] = 1; for (int i = 1; i < Maxn; i++) pw[i] = 2ll * pw[i - 1] % mod; cin >> n >> q; cin >> s; Create(1, 0, n - 1); for(int a0 = 0; a0 < q; a0++){ int typ, i, j, v; scanf("%d %d %d", &typ, &i, &j); if (typ == 1) { scanf("%d", &v); Update(1, 0, n - 1, i, j, v); } else { int mask = getMask(1, 0, n - 1, i, j); int dif = __builtin_popcount(mask); int res = ll(dif + 1) * pw[j - i + 1 - dif] % mod; res = (res - 1 + mod) % mod; printf("%d\n", res); } } return 0; }