from itertools import product N, K = map(int, input().split()) A = [input() for _ in range(N)] B = [[""]*N*K for _ in range(N*K)] for i, j in product(range(N*K), repeat=2): B[i][j] = A[i//K][j//K] print(*map("".join, B), sep="\n")