#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; namespace hc_q4 { template vector readVec(istream& ss, int N); void shift(vector& A, int i, int j, int t) { for (int x=i; x <= j; x++) { for (int y = 0; y < t; y++) { if (A[x] == 'z') A[x] = 'a'; else A[x]++; } } } bool canBePalindrome(vector& A) { if (A.size()==1) return true; unordered_map M; for (auto c : A) M[c]++; int odd = 0; for (auto it : M) { if (it.second % 2 == 1) { odd++; if (odd > 1) break; } } return odd <= 1; } int subsets_h(const std::vector & A, size_t i, std::vector & subset) { if (i == A.size()) { if (canBePalindrome(subset)) return 1; return 0; } else { int c1 = subsets_h(A, i + 1, subset); subset.push_back(A[i]); int c2 = subsets_h(A, i + 1, subset); subset.pop_back(); return c1+c2; } } int count(vector& A, int i, int j) { vector B(A.begin()+i, A.begin()+i + (j-i) +1); vector S; int x = subsets_h(B, 0, S); if (x > 0) x--; return x % (1000000000 + 7); } void test(istream& ss) { int N, Q; ss >> N >> Q; string S; ss >> S; vector A(S.begin(), S.end()); int a,b,t; for (int i = 0; i < Q; i++) { int op; ss >> op; if (op == 1) { ss >> a >> b >> t; shift(A, a, b, t); } else { ss >> a >> b; int r = count(A, a, b); cout << r << '\n'; } } } template vector readVec(istream& ss, int N) { vector A(N); for (auto& i : A) ss >> i; return A; } void test(string t) { istringstream iss(t); istream& is(iss); test(is); } void test() { test(cin); } } // namespace hc_q4 { using namespace hc_q4; int main(){ test(); return 0; }