Royal Journey
His Majesty King Bubei II wished to go around his possessions. At the same time , there are the following wishes for the route:
1) the route should take the shortest possible time (royal time is a very valuable thing and it should be protected);
2) the route must include all localities exactly once (if the king misses a locality, then its inhabitants will be outraged by the royal inattention and will stop paying taxes; if the king visits a locality more than once, then the inhabitants of other localities will also be outraged)
3) the route should start and end in the capital of the state (after going around his possessions, the king should immediately get down to business). The capital is included in the route exactly 2 times: as a departure point and as a destination, it cannot be an intermediate settlement on the route.
Write a program that finds such a route according to the road scheme of the kingdom or determines that it is impossible to fulfill all the requirements.
first, enter the number $N$ (natural, does not exceed 10) – the number of settlements of the kingdom. Then follows $N$ rows of $N$ numbers in each – the travel time between settlements (time is a non–negative integer, does not exceed 500; if time = 0, it means that there is no path between some settlements). Locality No. 1 is the capital of the state.
print the smallest total time that His Majesty will spend on detouring his possessions, or the number -1 if it is impossible to build a route with the specified properties.
1 0
0
2 0 1 1 0
2
2 0 85 85 0
170