R,K = map(int,input().split()) H,W = map(int,input().split()) S = [list(input()) for _ in range(H)] for i in range(R//90): S = list(zip(*S[::-1])) H1 = len(S) * K W1 = len(S[0]) * K S1 = [] for i in range(H1): tmp = [] for j in range(W1): tmp.append(S[i//K][j//K]) S1.append("".join(tmp)) for s in S1: print(s)