N, Q = map(int, input().split()) S = input() L = [] Y = [[] for _ in range(Q)] for i in range(Q): L.append(list(map(int, input().split()))) for i in list(set([p[0] for p in L])): a = [[j, x] for j, x in enumerate(L) if x[0] == i] for k in list(set([q[1][1] for q in a])): b = [[y[1][2], y] for y in a if y[1][1] == k] s = ''.join(sorted(S[(i-1):k])) for l in list(set([r[0] for r in b])): for m in b: if l==m[0]: Y[l-1] = s[l-1] for i in range(Q): print(Y[i])