N,K = (int(i) for i in input().split())
S = input()

a = [S]
res = []

for i in range(K):
  
  for k in a:
    Ss = k[::-1]
    SSs = k + Ss
    a = []
  
    for j in range(len(S)):
      a.append(SSs[j:len(S)+j])
      res.append(SSs[j:len(S)+j])
  
print(min(res))