Statement
You are given a weighted undirected graph with vertices. The weight of the edge between vertices and is . If , that edge does not exist.
Start at vertex , visit vertices in strictly increasing order until reaching , and then visit vertices in strictly decreasing order before returning to . Before returning to the start, you must visit every vertex exactly once, and every edge used must exist. Find any valid visiting order with minimum total edge weight.
Input
The input is given in the following format:
Each case is given in the following format:
Output
For each case, print only if no valid visiting order exists.
Otherwise, print its minimum total weight on the first line and the vertex numbers visited before returning to the start on the second line, separated by spaces. Here , and is a permutation of through . Include the edge from back to in the total weight. If several answers exist, print any of them.
Constraints
- .
- .
- , where means that the edge does not exist.
- .
- .
- The sum of over all cases is at most .