Implement a Traveling Salesman problem variant with additional constraints and ensure it passes the test cases.