implement the solution for TSP