N,Q = map(int,input().split()) S = list(input()) for _ in range(Q): l,r,x = map(int,input().split()) A = sorted(S[l-1:r]) print(A[x-1])