You are given an undirected graph with positive costs at the edges. Please compute the cheapest cycle of the graph.
Input consists of several cases, each with the number of vertices , followed by the number of edges , followed by triples to indicate an edge connecting and with cost , where and . Vertices are numbered starting from 0. For every pair of vertices, there is at most one edge connecting them. Assume and .
For every case, print the cost of the cheapest cycle of the graph.
Input
3 3 0 1 10 0 2 20 1 2 30 7 8 5 0 70 4 5 10 0 4 40 2 1 40 3 6 1 5 2 30 4 1 30 4 2 80
Output
60 110