#include using namespace std; #define endl '\n' #define ff first #define ss second #define mp make_pair #define pb push_back typedef long long llong; typedef pair pii; const int mod = 1e9 + 7; bool is_pali(string &str) { vector cnt(26); for (char c : str) { cnt[c - 'a']++; } int odd_cnt = 0; for (int val : cnt) { if (val % 2) odd_cnt++; } return odd_cnt <= 1; } void solve() { int n, q; cin >> n >> q; string str; cin >> str; for (int _q = 0; _q < q; _q++) { int type; cin >> type; if (type == 1) { int s, e, t; cin >> s >> e >> t; for (int i = s; i <= e; i++) { char c = str[i]; char shift_c = (char)( ( (c - 'a') + t ) % 26 ) + 'a'; str[i] = shift_c; } } else if (type == 2) { int s, e; cin >> s >> e; int len = e - s + 1; int subsets = 1 << len; int ans = 0; for (int mask = 1; mask < subsets; mask++) { string curr; for (int i = 0; i < len; i++) { if (mask & (1 << i) ) { curr.pb(str[i + s]); } } // cout << "curr: " << curr << endl; if (is_pali(curr)) ans++; } cout << (ans % mod) << endl; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL ifstream in("in"); cin.rdbuf(in.rdbuf()); #endif solve(); }