#coding:utf-8
tp= input().split()
N = int(tp[0])
K = int(tp[1])
S = input()
Sd=""
for i in range(K):
  T=S[::-1]
  U=S+T
  rtp=[]
  for h in range(K):
    rtp.append(U[h:h+N])
  rtp.sort()
  Sd=rtp[0]
  S=Sd
print(Sd)