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


def get_kouho(SS):
    Scon = SS + SS[::-1]
    topchar = sorted(list(Scon))[0]
    smallScon = [Scon[i:i + N] for i in range(N) if Scon[i]==topchar]
    smallScon.sort()
    smallScon_rev = [Scon[i:i + N][::-1] for i in range(N) if Scon[i+N]==topchar]
    smallScon_rev.sort()
    # print(smallScon)
    # print(smallScon_rev)
    kouho1 = smallScon[0]
    kouho2 = smallScon_rev[0]
    return kouho1, kouho2[::-1]  # kouho2はrevしてるので元に戻す


kouho1, kouho2 = get_kouho(S)
# print('kouhos',kouho1, kouho2)

for i in range(K - 1):
    kouho11, kouho12 = get_kouho(kouho1)
    kouho21, kouho22 = get_kouho(kouho2)
    kouhos = kouho11, kouho12, kouho21, kouho22
    print('kouhos', kouhos)
    kouho1 = sorted(kouhos)[0]
    kouho2 = sorted([s[::-1] for s in kouhos])[0][::-1]

print(sorted([kouho1, kouho2])[0])