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

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

for i in range(K):
    S = E(S, i)
print(S)

