import math def palindrome(s): total = 0 sets = [] for i in set(s): sets.append((i,s.count(i))) even = [] odd = [] for i in sets: if(i[1]%2 == 0): even.append(i[1]) else: odd.append(i[1]) total += sum([(math.pow(2,x)-1)%1000000007 for x in even]) total += len(odd)%1000000007 total = (total + (len(even)*len(odd)))%1000000007 return total l,q = [int(x) for x in input().split()] s = [ord(x)-97 for x in list(input())] for j in range(q): k = input().split() #SHIFTING if(len(k) == 4): a,b,t = k[1],k[2],k[3] for i in range(int(a),int(b)+1): s[i] = (s[i]+(int(t)%26))%26 #PALINDROME else: a,b = int(k[1]),int(k[2]) #print(palindromeSubStrs(''.join([chr(97+x) for x in s[a:b+1]]))) print(int(palindrome(s[a:b+1])))