N,K=map(int,input().split()) A=[input() for i in range(N)] B=[[None]*N*K for x in range(N*K)] for x in range(N*K): for y in range(N*K): B[x][y]=A[x//K][y//K] for x in range(N*K): print(*B[x],sep="")