N, K = map(int, input().split()) S = input() for i in range(N-K+1): s =S[:i] + S[i:i+K][::-1] + S[i+K:] S = s print(s)