#include #define si(n) scanf("%d",&n); #define pi(n) printf("%d\n",n); #define pl(n) printf("%lld\n",n); #define sl(n) scanf("%lld",&n); #define pd(n) printf("%lf\n",n); #define ss(s) scanf("%s",s); #define ps(s) printf("%s\n",s); #define pb push_back #define ll long long int #define maxn 100005 #define sqrtn 317 #define maxm 100005 #define minv(a,b,c) min(a,min(b,c)) #define pii pair #define pll pair #define eps 1e-9 #define mod 1000000007 #define psi pair < string,ll> #define mp make_pair using namespace std; char s[maxn]; int tree[4*maxn][26]; ll lazy[4*maxn]; int n; int modulo(int a,int b,int c){ long long x=1,y=a; while(b > 0){ if(b%2 == 1){ x=(x*y)%c; } y = (y*y)%c; b /= 2; } return x%c; } void combine(int index,int l,int r) { for(int i=0;i<26;i++) { tree[index][i]=tree[l][i]+tree[r][i]; } } void update_values(int index,ll t) { t=t%26; int arr[26]; for(int i=0;i<26;i++) { arr[(i+t)%26]=tree[index][i]; } for(int i=0;i<26;i++) { tree[index][i]=arr[i]; } } void build_tree(int index,int l,int r) { if(l>r) return ; if(l==r) { tree[index][s[l]-'a']=1; } else { int mid=(l+r)/2; build_tree(2*index,l,mid); build_tree(1+2*index,mid+1,r); combine(index,2*index,1+2*index); } } int query(int index,int l,int r,int ql,int qr,int c) { if(lazy[index]!=0) { update_values(index,lazy[index]); if(l!=r) { lazy[2*index]=(lazy[2*index]+lazy[index])%26; lazy[1+2*index]=(lazy[1+2*index]+lazy[index])%26; } lazy[index]=0; } if(l>=ql&&r<=qr) { return tree[index][c]; } int mid=(l+r)/2; if(qr<=mid) return query(2*index,l,mid,ql,qr,c); else if(ql>mid) return query(2*index+1,mid+1,r,ql,qr,c); else { int lef= query(2*index,l,mid,ql,qr,c); int rig= query(2*index+1,mid+1,r,ql,qr,c); return lef+rig; } } void update(int index,int l,int r,int ql,int qr,int t) { if(lazy[index]!=0) { update_values(index,lazy[index]); if(l!=r) { lazy[2*index]=(lazy[2*index]+lazy[index])%26; lazy[1+2*index]=(lazy[1+2*index]+lazy[index])%26; } lazy[index]=0; } if(qr< l || l>r|| ql > r) return ; if(l>=ql&&r<=qr) { update_values(index,t); if(l!=r) { lazy[2*index]=(lazy[2*index]+t)%26; lazy[1+2*index]=(lazy[1+2*index]+t)%26; } return; } int mid=(l+r)/2; { update(2*index,l,mid,ql,qr,t); update(1+index*2,mid+1,r,ql,qr,t); } combine(index,2*index,1+2*index); } ll compute(int ql,int qr) { ll arr[26]; ll val; ll temp=1; int count=0; for(int i=0;i<26;i++) { val=query(1,0,n-1,ql,qr,i); if(val!=0) { arr[i]=modulo(2,val-1,mod); temp=(temp*arr[i])%mod; count++; } } ll ans=(temp*count)%mod; ans=(ans+temp-1+mod)%mod; return ans; } int main() { int q; si(n);si(q); ss(s); build_tree(1,0,n-1); for(int i=0;i