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