n,q=map(int,input().split())
s=input()
r=[1]*n
w={}
for i,j in enumerate(s):
    if j in w:
        w[j].append(i)
    else:
        w[j]=[i])
for i in w:
    w[i].sort()
for i in range(q):
    t,d=map(str,input().split())