n, k = [int(x) for x in input().split()] a = [input() for _ in range(n)] nk = n * k b = [["."] * nk for _ in range(nk)] for i in range(nk): for j in range(nk): b[i][j] = a[i//k][j//k] for l in b: print("".join(l))