Takahashi has a string S of length N consisting of lowercase English letters. He will perform the following operation K times: Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order. Then, let S' be some contiguous substring of U with length N, and replace S with S'. Among the strings that can be the string S after the K operations, find the lexicographically smallest possible one.

Constraints:
1 ≤ N ≤ 5000
1 ≤ K ≤ 10^9
|S| = N
S consists of lowercase English letters.

Input:
N K
S

Output:
Print the lexicographically smallest possible string that can be the string S after the K operations.

Sample Input 1:
5 1
bacba

Sample Output 1:
aabca

Sample Input 2:
10 2
bbaabbbaab

Sample Output 2:
aaaabbaabb

# Buggy version:
n, k = map(int, input().split())
s = input()
rev_s = s + s[::-1]
mido = "z" * n
for i in range(n + 1):
    if mido > rev_s[i:i + n]:
        mido = rev_s[i:i + n]
ind = float("inf")
for i in range(n):
    if mido[i] != mido[0]:
        if i > ind:
            ind = i
ans = ind * (2 ** (k - 1))
print((mido[0] * ans + mido[ind:ind + n - ans])[:n])

# Fixed version:
n, k = map(int, input().split())
s = input()
rev_s = s + s[::-1]
mido = "z" * n
for i in range(n + 1):
    if mido > rev_s[i:i + n]:
        mido = rev_s[i:i + n]
ind = float("inf")
for i in range(n):
    if mido[i] != mido[0]:
        if i < ind:
            ind = i
ans = ind * (2 ** min(k - 1, 20))
print((mido[0] * ans + mido[ind:ind + n - ans])[:n])

# Buggy version:
n,k=map(int,input().split())
s=input()
t=s[::-1]
u="".join([s,t])
ls=[]
for i in range(n):
  ls.append(u[i:i+n])
ls.sort()
k-=1
x=list(ls[0])
if 2**k<n:
  y=n-2**k
  print(x[0]*(2**k)+x[1:y+1])
else:
  print(x[0]*n)

# Fixed version:
n,k=map(int,input().split())
s=input()
t=s[::-1]
u="".join([s,t])
ls=[]
for i in range(n):
  ls.append(u[i:i+n])
ls.sort()
k-=1
x=ls[0]
cnt=1
for i in range(1,n):
  if x[0]==x[i]:
    cnt+=1
  else:
    break
if cnt*2**k<n:
  y=n-cnt*2**k
  print(x[0]*(cnt*2**k)+x[cnt:y+cnt])
else:
  print(x[0]*n)

# Buggy version:
n, k = map(int, input().split())
s = input()

if k > 5000 * 26:
    k = 5000 * 26

for i in range(k):
    sList = []
    t = (s[::-1])
    u = s + t
    for j in range(n+1):
        sList.append(u[j:(j + n)])
    sList.sort()
    s = sList[0]

print(s)


# Fixed version:
n, k = map(int, input().split())
s = input()

if k > 5000 * 26:
    k = 5000 * 26

if k != 1:
    for i in range(k - 1):
        sList = []
        t = (s[::-1])
        u = s + t
        for j in range(0, n+1):
            sList.append((u[j:(j + n)])[::-1])
        sList.sort()
        if s == sList[0][::-1]:
            break
        s = sList[0][::-1]


for i in range(1):
    sList = []
    t = (s[::-1])
    u = s + t
    for j in range(0, n+1):
        sList.append(u[j:(j + n)])
    sList.sort()
    s = sList[0]

print(s)

# Buggy version:
n,k=map(int,input().split())
s=input()
d=s+s[::-1]
d=d[::-1]
r=d[:n]
e=d[:n]
for i in range(n):
    e=e[1:]+d[n+i]
    r=min(r,e)
t=1
qo=r[0]
for i in range(1,n):
    if qo==r[i]:
        t+=1
    else:
        break
r=r[::-1]
print(r)
for i in range(k-1):
    p=r+r[n-t:]
    p=p[::-1]
    p=p[:n]
    if r==p:
        break
    else:
        r=p[::-1]
        t+=t
print(r[::-1])

# Fixed version:
n,k=map(int,input().split())
s=input()
d=s+s[::-1]
d=d[::-1]
r=d[:n]
e=d[:n]
for i in range(n):
    e=e[1:]+d[n+i]
    r=min(r,e)
t=1
qo=r[0]
for i in range(1,n):
    if qo==r[i]:
        t+=1
    else:
        break
r=r[::-1]
for i in range(k-1):
    p=r+r[n-t:]
    p=p[::-1]
    p=p[:n]
    if r==p:
        break
    else:
        r=p[::-1]
        t+=t
print(r[::-1])