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