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