def E(S, N):
    T = S[::-1]
    U = S+T
    return [U[i:N+i] for i in range(N)]

N, K = input().split()
N, K = int(N), int(K)
S = [input()]

for i in range(K):
    memory = []
    for s in S:
        memory += E(s, N)
    S = sorted(memory)[:N//2]
print(S[0])