import java.util.Scanner; public class Solution { private static final long MOD = 1000000007; private static long fac(long num) { long ans = 1; for (int i = 2; i <= num; i++) { ans = (ans * i) % MOD; } return ans; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int q = in.nextInt(); String s = in.next(); char[] chars = s.toCharArray(); while (q-- > 0) { int type = in.nextInt(); if (type == 1) { int i = in.nextInt(); int j = in.nextInt(); int t = in.nextInt() % 26; for (int idx = i; idx <= j; idx++) chars[idx] = (char) ((((chars[idx] - 'a') + t) % 26) + 'a'); } else { int i = in.nextInt(); int j = in.nextInt(); int len = j - i + 1; int[] counts = new int[26]; for (int idx = i; idx <= j; idx++) { counts[chars[idx] - 'a']++; } long numPal = len; long numSingles = 0; long numDoubles = 0; for (int idx = 0; idx < 26; idx++) { numDoubles += counts[idx] / 2; if (counts[idx] % 2 == 1) numSingles++; } for (int l = 2; l <= len; l++) { if (numDoubles < l / 2) { break; } long permutations; if (l % 2 == 0) { permutations = (fac(numDoubles) / fac(numDoubles - l)) % MOD; } else { long leftovers = (numSingles + Math.max(2 * (numDoubles - l - 1), 0)); permutations = (((fac(numDoubles) * leftovers) % MOD) / fac(numDoubles - l - 1) % MOD) % MOD; } numPal = (numPal + permutations) % MOD; } System.out.println(numPal); } } in.close(); } }