n, k = map(int, input().split()) S = [input() for _ in range(n)] m = n * k T = [["."] * m for _ in range(m)] for i in range(m): for j in range(m): T[i][j] = S[i // k][j // k] for row in T: print(*row, sep="")