n,k=list(map(int,input().split()))

s=eval(input())

r=list(range(n))

u=min((s+s[::-1])[i:]for i in r)

i=min(i for i in r if u[i]!=u[0])

print(((u[0]*min(i<<k-1,n)+u[i:])[:n]))
n,k=map(int,input().split())

s=input()

r=range(n)

u=min((s+s[::-1])[i:]for i in r)

for i in r:u[i]==u[0]or exit(print((u[0]*min(i<<k-1,n)+u[i:])[:n]))

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

n, k = map(int, input().split())
s = input()
r = range(n)
u = min((s + s[::-1])[i:] for i in r)
for i in r:
    u[i] == u[0] or exit(print((u[0] * min(i << k - 1, n) + u[i:])[:n]))

-n, k = list(map(int, input().split())) -s = eval(input()) -r = list(range(n)) +n, k = map(int, input().split()) +s = input() +r = range(n) -i = min(i for i in r if u[i] != u[0]) -print(((u[0] * min(i << k - 1, n) + u[i:])[:n])) +for i in r: +    u[i] == u[0] or exit(print((u[0] * min(i << k - 1, n) + u[i:])[:n]))