import bisect n,q = map(int,input().split()) s = input() lrx = [[int(i)-1 for i in input().split()] for j in range(q)] li = [[0 for i in range(n)] for j in range(n)] for i in range(n): li[i][i] = [ord(s[i])] for j in range(i+1,n): tmp = ord(s[j]) li[i][j] = li[i][j-1][:] #print(li[i][j]) bisect.insort(li[i][j],tmp) #print(li) #exit() for i in range(q): #print(li[lrx[i][0]][lrx[i][1]]) print(chr(li[lrx[i][0]][lrx[i][1]][lrx[i][2]]))