import collections N, Q = [int(x) for x in input().split()] S = input() queries = [[int(x) for x in input().split()] for _ in range(Q)] # print(queries) for x in queries: string_data = S[x[0]-1:x[1]] # print(string_data) # print(list(string_data)) # print(sorted(list(string_data))) # print(sorted(list(string_data))[x[2]-1]) word = "" res = collections.Counter(list(string_data)) for i, (k, v) in enumerate(sorted(res.items())): if i > x[2]: break word += k * v print(word[x[2]-1])