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


if N < 2**K:
    S_young = sorted(list(S))[0]
    print(S_young*N)
    
else:
    word=S
    S=S+S[::-1]
    for i in range(K):
        for j in range(N-1):
            if word > S[1+j:1+j+N]:
                word = S[1+j:1+j+N]
        S = word[::-1]+word
    print(word)