N,K=map(int,input().split())
S=input()
K=min(K,20)
for i in range(K):
    X=[]
    U=S+S[::-1]
    if (K-i)%2==1:
        for j in range(N+1):
            X.append(U[j:N+j])
        S=min(X)
    else:
        for j in range(N+1):
            X.append(U[j:N+j][::-1])
        S=min(X)[::-1]

    #print(X,S)
print(S)
