n, k = map(int, input().split())
s = input()
u = s + s[::-1]
t = min(u[i:i + n] for i in range(n + 1))
h = t[0]
i = min(i for i in range(n) if t[i] != h)
j = i << min(k - 1, n.bit_length())
print((h * j + t[i:i + n - j])[:n])
