N, K = map(int, input().split())
S = list(input())

f = S[K-1:]
r =S[:K-1] if (N - K + 1) % 2 == 0 else list(reversed(S[:K-1]))
print(f)
print(r)
print(''.join(f + r))