#!/usr/bin/env python3 import sys MOD = 998244353 input = sys.stdin.readline def main(): 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:] print(S) return if __name__ == '__main__': main()