R, K = map(int, input().split()) H, W = map(int, input().split()) C = [input().strip() for _ in range(H)] for _ in range(R // 90): C = [x[::-1] for x in zip(*C)] print("\n".join( "\n".join( "".join(y * K for y in x) for _ in range(K) ) for x in C ))