#T42. 繁忙的都市

繁忙的都市

Description

City C is a very busy metropolis where the roads are extremely congested. As a result, the mayor has decided to renovate some of the roads. The roads in City C are distributed as follows: there are n intersections, and some intersections are connected by roads. There is at most one road between any two intersections. These roads are bidirectional and connect all intersections directly or indirectly. Each road has a score, where a smaller score indicates that the road is busier and more in need of renovation. However, the city government has limited funds, and the mayor hopes to renovate as few roads as possible. Therefore, he has proposed the following requirements:

  1. The renovated roads must connect all intersections directly or indirectly.
  2. Under the condition of requirement 1, the number of renovated roads should be as few as possible.
  3. Under the conditions of requirements 1 and 2, the maximum score among the renovated roads should be as small as possible.

As the city planning bureau, you must make the optimal decision and select which roads should be renovated.

Input Format

The first line contains two integers n and m, indicating that the city has n intersections and m roads. The next m lines describe each road, with u, v, c indicating that there is a road between intersections u and v with a score of c. (1 ≤ n ≤ 300, 1 ≤ c ≤ 10000).

Output Format

Two integers s and max, representing the number of roads you have selected and the maximum score among those roads.

4 5
1 2 3
1 4 5
2 4 7
2 3 6
3 4 8


3 6