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