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

def get_kouho(SS):
  Scon = SS+SS[::-1]
  smallScon = [Scon[i:i+N] for i in range(N)]
  smallScon_rev = [s[::-1] for s in smallScon]
  #print(smallScon)
  #print(smallScon_rev)
  kouho1 = sorted(smallScon)[0]
  kouho2 = sorted(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[::-1])
  kouhos =kouho11, kouho12, kouho21, kouho22
  print('kouhos',kouhos)
  kouho1 = sorted(kouhos)[0]
  kouho2 = sorted([s[::-1] for s in kouhos])[0]

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