import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np R,K = map(int,readline().split()) H,W = map(int,readline().split()) C = np.frombuffer(read(),'S1').reshape(H,-1)[:,:W].astype('U1') D = np.repeat(C,K,axis=0).repeat(K,axis=1) for _ in range(R//90): D = D.T[::-1] print('\n'.join(''.join(row) for row in D))