#include using namespace std; #define ll long long #define mod 1000000007 #define eps 1e-13 #define PI 3.14159265359 #define INF 1000000011 #define INFLL 1000000000000000011LL #define space printf(" ") #define endl printf("\n") #define vi vector #define vll vector #define vc vector #define vs vector #define pii pair #define pll pair #define pil pair #define pli pair #define pcc pair #define mp make_pair #define F first #define S second #define pb(x) push_back(x) #define fo(i,a,n) for(i = (a); i < (n); i++) #define foi(i,a,n) for(int i = (int)(a); i < (int)(n); i++) #define foll(i,a,n) for(long long i = (long long)(a); i < (long long)(n); i++) #define sd(x) scanf("%d", &(x)) #define pd(x) printf("%d", (x)) #define pdn(x) printf("%d\n", (x)) #define slld(x) scanf("%lld", &(x)) #define plld(x) printf("%lld", (x)) #define plldn(x) printf("%lld\n", (x)) #define sllf(x) scanf("%llf", &(x)) #define pllf(x) printf("%.9llf", (x)) #define pllfn(x) printf("%.9llf\n", (x)) #define sch(x) scanf("%c", &(x)) #define pch(x) printf("%c", (x)) #define pchn(x) printf("%c\n", (x)) #define gtl(x) getline(cin, (x)) #define flsh fflush(stdout) #define sws ios::sync_with_stdio(false); cin.tie(0) #define gcd __gcd #define clr(x) memset(x,0,sizeof(x)) #define all(a) (a).begin(), (a).end() #define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i) #define sz(a) (int)((a).size()) /*ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a%b); }*/ ll modx(ll Base, ll exponent) { ll ans = 1; if(Base == 1) return Base; while(exponent) { if(exponent & 1) ans = (ans * Base)%mod; Base = (Base * Base)%mod; exponent = exponent >> 1; } return ans; } ll inmodx(ll num) { return (modx(num, mod-2LL)); } struct node { node() { } }; bool cmp() { return false; } const int N = 100009; int st[4*N][26], a[N], ln[4*N], cnt[26]; void build(int node, int l, int r) { if(l == r) { st[node][a[l]] = 1; return; } int mid = (l+r)>>1, i; build(2*node, l, mid); build(2*node+1, mid+1, r); fo(i,0,26) st[node][i] = st[2*node][i] + st[2*node+1][i]; return; } void update(int node, int l, int r, int p, int q, int val) { if(l > r) return; int temp[26], i; if(ln[node] > 0) { ln[2*node] = (ln[2*node] + ln[node])%26; ln[2*node+1] = (ln[2*node+1] + ln[node])%26; } if(l > q || r < p) { if(ln[node] > 0) { fo(i,0,26) temp[i] = st[node][i]; fo(i,0,26) st[node][(i+ln[node])%26] = temp[i]; ln[node] = 0; } return; } if(l >= p && r <= q) { ln[node] = (ln[node] + val)%26; ln[2*node] = (ln[2*node] + val)%26; ln[2*node+1] = (ln[2*node+1] + val)%26; fo(i,0,26) temp[i] = st[node][i]; fo(i,0,26) st[node][(i+ln[node])%26] = temp[i]; ln[node] = 0; return; } ln[node] = 0; int mid = (l+r)>>1; update(2*node, l, mid, p, q, val); update(2*node+1, mid+1, r, p, q, val); fo(i,0,26) st[node][i] = st[2*node][i] + st[2*node+1][i]; return; } void query(int node, int l, int r, int p, int q) { if(l > r) return; int temp[26], i; if(ln[node] > 0) { ln[2*node] = (ln[2*node] + ln[node])%26; ln[2*node+1] = (ln[2*node+1] + ln[node])%26; } if(l > q || r < p) { if(ln[node] > 0) { fo(i,0,26) temp[i] = st[node][i]; fo(i,0,26) st[node][(i+ln[node])%26] = temp[i]; ln[node] = 0; } return; } if(l >= p && r <= q) { if(ln[node] > 0) { fo(i,0,26) temp[i] = st[node][i]; fo(i,0,26) st[node][(i+ln[node])%26] = temp[i]; ln[node] = 0; } fo(i,0,26) cnt[i] += st[node][i]; return; } ln[node] = 0; int mid = (l+r)>>1; query(2*node, l, mid, p, q); query(2*node+1, mid+1, r, p, q); fo(i,0,26) st[node][i] = st[2*node][i] + st[2*node+1][i]; return; } int main() { // freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); // freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout); sws; int n, q, i, l, r, t, x, ep, op; ll ans, temp, y; string s; cin >> n >> q; cin >> s; fo(i,0,n) a[i+1] = s[i]-'a'; build(1,1,n); while(q--) { cin >> x >> l >> r; if(x == 1) { cin >> t; if(t % 26 != 0) update(1,1,n,l+1,r+1,t%26); } else { fo(i,0,26) cnt[i] = 0; query(1,1,n,l+1,r+1); temp = 1LL; y = 0LL; fo(i,0,26) { if(cnt[i] > 0) { y++; temp = (temp * (modx(2LL, (ll)(cnt[i]-1))))%mod; } } ans = (y*temp + temp + mod - 1LL)%mod; cout << ans << '\n'; } } return 0; }