#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef std::vector vi; typedef std::vector vb; typedef std::vector vs; typedef std::vector vd; typedef std::vector vll; typedef std::vector > vvi; typedef vector vvvi; typedef vector vvll; typedef std::vector > vpi; typedef vector vvpi; typedef std::pair pi; typedef std::pair pll; typedef std::vector vpll; const long long mod = 1000000007; #define all(c) (c).begin(),(c).end() #define sz(c) (int)(c).size() #define forn(i, a, b) for(int i = a; i < b; i++) #define pb push_back #define mp make_pair const int MAXN = 100009; int n; int t[4*MAXN]; int lazy[4*MAXN]; vi d(1,1); void go(int v, int add) { int s = (26-add%26)%26; int en = t[v] % d[s]; int st = t[v] / d[s]; t[v] = st + en*d[26-s]; } void push(int v) { if (lazy[v] == 0) return; go(v , lazy[v]); if(v<2*n) { lazy[v*2] += lazy[v]; lazy[v*2 + 1] += lazy[v]; } lazy[v] = 0; } void build (vi & a, int v, int tl, int tr) { if (tl == tr) { t[v] = d[a[tl]]; } else { int tm = (tl + tr) / 2; build (a, v*2, tl, tm); build (a, v*2+1, tm+1, tr); t[v] = t[v*2]|t[v*2+1]; } } void update (int v, int tl, int tr, int l, int r, int add) { push(v); if (l > r) return; if (l == tl && tr == r) { lazy[v] = (lazy[v] +add)%26; push(v); } else { int tm = (tl + tr) / 2; update (v*2, tl, tm, l, min(r,tm), add); update (v*2+1, tm+1, tr, max(l,tm+1), r, add); t[v] = t[v*2]|t[v*2+1]; } } int get (int v, int tl, int tr, int l, int r) { push(v); if(l>r) return 0; if (l == tl && tr == r) return t[v]; int tm = (tl + tr) / 2; return get (v*2, tl, tm, l, min(r,tm)) | get (v*2+1, tm+1, tr, max(l,tm+1), r); } int main() { forn(i,0,26) d.pb(d.back()*2); vll codd, ceven; int q; scanf("%d %d\n", &n, &q); ll d2 = 1; codd.pb(0); ceven.pb(1); forn(i,0,n+1) { codd.pb(d2); ceven.pb(d2); d2=(d2*2)%mod; } string s; getline(cin, s); vi a; forn(i,0,n) a.pb((int)(s[i]-'a')); build(a, 1, 0, n-1); vll dd2(1,1); forn(i,0,n) dd2.pb((dd2.back()*2)%mod); forn(asf,0,q) { int tp; scanf("%d", &tp); if(tp == 1) { int l,r,s; scanf("%d %d %d", &l, &r, &s); s=s%26; update(1,0,n-1,l,r,s); } else if(tp==2) { int l,r; scanf("%d %d", &l, &r); auto x = get(1,0,n-1,l,r); int num = 0; forn(i,0,26) if(x&d[i]) num++; ll cand = dd2[r-l+1-num]; ll ans = cand-1; forn(i,0,26) { if(x&d[i]) ans = (ans+cand)%mod; } printf("%lld\n", ans); } } }