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