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)
