N,K = map(int, input().split())
S = input()
candidates = []
for i in range(K):
    S += S[::-1]
    for j in range(len(S)):
        if len(S)-(j+N) >= 0:
            candidates.append(S[j:j+N])
        else:
            remain = len(S[j:])
            S[:N-remain]
            candidates.append(S[j:] + S[:N-remain])
    candidates = sorted(candidates)
    S = candidates[0]
print(S)
