#include #include #include #include using namespace std; #define ll long long #define REP(i, N) for(int (i)=0; (i)< (N); (i)++) #define pb push_back #define mp make_pair #define MAX 1234567 int tree[MAX][29] = {0}; // To store segment tree int lazy[MAX][29] = {0}; // To store pending updates void updateRangeUtil(int si, int ss, int se, int us, int ue, int diff, int let) { //printf("%d %d %d %d %d %d %d\n", si, ss, se, us, ue, diff, let); if (lazy[si][let] != 0) { tree[si][let] += (se-ss+1)*lazy[si][let]; if (ss != se) { lazy[si*2 + 1][let] += lazy[si][let]; lazy[si*2 + 2][let] += lazy[si][let]; } lazy[si][let] = 0; } if (ss>se || ss>ue || se=us && se<=ue) { tree[si][let] += (se-ss+1)*diff; if (ss != se) { lazy[si*2 + 1][let] += diff; lazy[si*2 + 2][let] += diff; } return; } int mid = (ss+se)/2; updateRangeUtil(si*2+1, ss, mid, us, ue, diff, let); updateRangeUtil(si*2+2, mid+1, se, us, ue, diff, let); tree[si][let] = tree[si*2+1][let] + tree[si*2+2][let]; } void updateRange(int n, int us, int ue, int diff, int let) { updateRangeUtil(0, 0, n-1, us, ue, diff, let); } int getSumUtil(int ss, int se, int qs, int qe, int si, int let) { if (lazy[si][let] != 0) { tree[si][let] += (se-ss+1)*lazy[si][let]; if (ss != se) { lazy[si*2+1][let] += lazy[si][let]; lazy[si*2+2][let] += lazy[si][let]; } lazy[si][let] = 0; } if (ss>se || ss>qe || se=qs && se<=qe) return tree[si][let]; int mid = (ss + se)/2; return getSumUtil(ss, mid, qs, qe, 2*si+1, let) + getSumUtil(mid+1, se, qs, qe, 2*si+2, let); } #define MOD 1000000007 int getSum(int n, int qs, int qe, int let) { return getSumUtil(0, n-1, qs, qe, 0, let); } int n,q; ll pow2[111111]; char str[111111]; long long modpow(int n, int k) { if(k == 0) return 1; long long y = modpow(n, k/2); y = (y*y)%MOD; if(k&1) y = (y*n)%MOD; return y; } int main() { scanf("%d%d", &n, &q); pow2[0] = 1; REP(i, n) if(i) pow2[i] = (pow2[i-1]*2)%MOD; scanf("%s", str); REP(i, n) { updateRange(n, i, i, 1, str[i]-'a'); } REP(qq, q) { int t; scanf("%d", &t); if(t == 1) { int a,b,s; scanf("%d%d%d",&a,&b,&s); } else { int a,b; scanf("%d%d", &a, &b); int sudych = 0, lichych = 0; ll ans = 0; vector cnts; REP(i, 26) { int cnt = getSum(n, a, b, i); cnts.pb(cnt); } ll cans = 1; REP(i, cnts.size()) { if(cnts[i] > 0) { cans = (cans*pow2[cnts[i]-1])%MOD; } } cans = (MOD+cans-1)%MOD; (ans += cans)%=MOD; REP(i, cnts.size()) { if(cnts[i]>0) { ll cans2 = pow2[cnts[i]-1]; REP(j, cnts.size()) { if(i == j || cnts[j] == 0) continue; cans2 = (cans2*pow2[cnts[j]-1])%MOD; } //printf("c2 %lld\n", cans2); (ans += cans2)%=MOD; } } printf("%lld\n", ans); } } return 0; }