alp='abcdefghijklmnopqrstuvwxyz'
n,q=map(int,input().split())
s=input()
cnt=[[0]*(n+1) for _ in range(26)]
for i in range(26):
    ch=alp[i]
    for j in range(n):
        if s[j]==ch:
            cnt[i][j+1]+=1
for i in range(26):
    for j in range(n):
        cnt[i][j+1]+=cnt[i][j]
for _ in range(q):
    l,r,x=map(int,input().split())
    ans=''
    for i in range(26):
        ans+=alp[i]*(cnt[i][r]-cnt[i][l-1])
    print(ans[x-1])