n, q = map(int, input().split())
s = list(input())
for i in range(q):
    l, r, x = map(int, input().split())
    t = s[l-1:r]
    t.sort()
    print(t[x-1])