N, K = map(int, input().split()) A = [input() for _ in range(N)] for i in range(N): s = '' for j in range(N): s += A[i][j]*K for _ in range(K): print(s)