n,k=map(int,input().split()) s=input() for i in range(n-k+1): ss=s[i:i+k] ss=ss[::-1] s=s[:i]+ss+s[i+k:] print(s)