As we all know, one of the most important inventions for modern-day public transportation is the subway, which brings much convenience to our daily-life and saves us from the congested traffic.
However, to hold the next ACM regional contest, you, as the mayor of city X, decided to upgrade the subway system of that city. There are some stations and roads in the city now, any road has a cost. To save money, you decided not to construct every road, but to make sure that there exist a path between every two stations.
Sorry, the mission isn't completed. You know, there are n stations in the city,some contestants visit other stations regularly to admire some so-called big cows. Being naturally averse to spending hours each day on commuting, you should help them to find a place to live for which the total travel time is minimal.
Every road has an ID, from 1 to m. If there are multiple approaches leading to the same minimal cost, the mayor prefers the one of which road IDs selected holds the smallest lexicographic order. For instance, rebuilding ID ( 1 3 5) and ID (2 4 5) will both ensure the minimum cost,the mayor will choose the former one.