#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long int palin(string s) { map m; int n = s.size(); int R[2][n+1]; s = "@" + s + "#"; for (int j = 0; j <= 1; j++) { int rp = 0; R[j][0] = 0; int i = 1; while (i <= n) { while (s[i - rp - 1] == s[i + j + rp]) rp++; R[j][i] = rp; int k = 1; while ((R[j][i - k] != rp - k) && (k < rp)) { R[j][i + k] = min(R[j][i - k],rp - k); k++; } rp = max(rp - k,0); i += k; } } s = s.substr(1, n); m[string(1, s[0])]=1; for (int i = 1; i <= n; i++) { for (int j = 0; j <= 1; j++) for (int rp = R[j][i]; rp > 0; rp--) m[s.substr(i - rp - 1, 2 * rp + j)]=1; m[string(1, s[i])]=1; } return m.size()-1; } int main(){ int n; int q; cin >> n >> q; string s; cin >> s; for(int a0 = 0; a0 < q; a0++){ int x; cin>> x; if(x == 1) { int i,j,t; cin>> i >> j >> t; for(int k=i;k<=j;k++) { if(s[k]+t <= 122) s[k] = (char)(s[k]+t); else s[k] = (char)(s[k]+t-122+96); } } else if(x == 2) { int i,j; cin>> i >> j; long int v = palin(s.substr(i,j-i+1)); long int z = 1000000007; v = v%z; cout<< v << endl; } } return 0; }