#!/bin/python import sys import itertools Z = 10**9 + 7 def shift(c, t): return (c+t) % 26 def q1(s, i, j, t): for c in xrange(i, j+1): s[c] = shift(s[c], t) def get_d(s): d = {} for i in set(s): if s.count(i) not in d: d[s.count(i)] = 0 d[s.count(i)] += 1 return d def get_total(l): n1 = sum(l)+1 n2 = sum([i*l[i] for i in range(1, len(l))]) return (n1*pow(2,n2,Z) - 1) % Z def palindromic_substrings(s): d = get_d(s) l = [] for k in range(max(d.keys())+1): if k in d: l.append(d[k]) else: l.append(0) return get_total(l[1:]) def q2(s, i, j): return palindromic_substrings(s[i:j+1]) def f(s, queries): for q in queries: if q[0] == 1: q1(s, q[1], q[2], q[3]) else: print q2(s, q[1], q[2]) letters = 'abcdefghijklmnopqrstuvwxyz' n,q = raw_input().strip().split(' ') n,q = [int(n),int(q)] s = raw_input().strip() s = [letters.index(c) for c in s] queries = [] for a0 in xrange(q): queries.append(map(int, raw_input().split(' '))) f(s, queries)