import sys input = sys.stdin.readline N, K = map(int, input().split()) A = [input().strip() for _ in range(N)] B = [["" for _ in range(N*K)] for _ in range(N*K)] for i in range(N*K): for j in range(N*K): B[i][j] = A[i//K][j//K] for b in B: print("".join(b))