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

lex_min = "z"
for char in S:
  lex_min = min(char, lex_min)

if (1 << (K - 1)) > N:
  print(lex_min * N)
else:
  U = S + S[::-1]
  candidates = []
  for i in range(N, N << 1):
    if U[i] == lex_min:
      M = U[i-N+1:i+1]
      if K > 1:
        candidates.append((1 << (K - 1)) * lex_min + M[:N - (1 << (K - 1))])
      else:
        candidates.append(M)
  print(min(candidates))
      