#include #include #include #include #include #include #define ll long long #define MAXN 100000 #define MODD 1000000007 using namespace std; int counts[26]; ll twopow[MAXN+2]; ll twopowinv[MAXN+2]; ll modpow(ll x, ll y) { x%=MODD; ll xs = x; ll answer = 1; while(y) { if (y&1) { answer = (answer * xs) % MODD; } y >>= 1; xs = (xs * xs) % MODD; } return answer; } int cumul_counts[26][MAXN+2]; int main() { int n,Q; cin>>n>>Q; string S; cin>>S; for(int i=0;i0?cumul_counts[j][i-1]:0)+(S[i]-'a'==j); } } twopow[0]=1; for(int i=1;i<=n+1;i++) { twopow[i]=(twopow[i-1]*2)%MODD; } for(int i=0;i<=n+1;i++) { twopowinv[i]=modpow(twopow[i],MODD-2); } for(int q=1;q<=Q;q++) { int type; cin>>type; if (type==1) { int i,j,t; cin>>i>>j>>t; for(int k=i;k<=j;k++) { S[k]=(S[k]-'a'+t)%26+'a'; } for(int i=0;i0?cumul_counts[j][i-1]:0)+(S[i]-'a'==j); } } } else { int i,j; cin>>i>>j; for(int t=0;t<26;t++) counts[t]=cumul_counts[t][j]-(i>0?cumul_counts[t][i-1]:0); ll all_even = 1; for(int t=0;t<26;t++) { all_even = (all_even * (counts[t]>0 ? twopow[counts[t]-1] : 1))%MODD; } ll ans = 0; for(int t=0;t<26;t++) { ll curr_even_inv = (counts[t]>0 ? twopowinv[counts[t]-1] : 0); ll curr_odd = (counts[t]>0 ? twopow[counts[t]-1] : 1); ll curr = ((all_even * curr_even_inv)%MODD * curr_odd)%MODD; ans = (ans + curr)%MODD; } ans = (ans + all_even + MODD-1)%MODD; cout << ans << endl; } } }