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