import sys input = sys.stdin.readline N,K=map(int,input().split()) A=[input().strip() for i in range(N)] MAP=[["."]*(N*K) for i in range(N*K)] for i in range(N): for j in range(N): if A[i][j]=="#": for k in range(i*K,i*K+K): for l in range(j*K,j*K+K): MAP[k][l]="#" for x in MAP: print("".join(x))