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