N, Q = map(int, input().split()) S = input() for i in range(Q): l, r, x = map(int, input().split()) s = ''.join(sorted(S[(l-1):r])) print(s[x-1])