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