Heavy Transportation

No attempts yetTime limit1sMemory limit128 MB

Problem

Hugo Heavy is expanding his business. He has to move a giant steel crane from where his customer built it to where it is needed, and every street along the route must be able to carry the crane's weight.

He has a map of the city listing every street and bridge together with its weight limit, but he has no idea how heavy the crane may become for the route to still support it. Working that out is your job.

The city has nn crossings, numbered from 11 to nn. Streets connect the crossings, and each street has a maximum weight it can carry. Find the maximum weight that can be transported from crossing 11 (Hugo's place) to crossing nn (the customer's place). This is the value of the route from 11 to nn whose smallest street weight limit is as large as possible. Every street can be travelled in both directions, and you may assume at least one route from 11 to nn always exists.

Input

The first line contains the number of scenarios (city maps).

Each scenario starts with a line containing two integers nn and mm: the number of crossings (1n10001 \le n \le 1000) and the number of streets. Each of the next mm lines contains three integers aa, bb, and ww, describing a street between crossings aa and bb with maximum allowed weight ww (1w10000001 \le w \le 1000000). There is at most one street between any pair of crossings.

Output

For each scenario, print a line Scenario #i:, where ii is the scenario number starting at 11, followed by a line containing the maximum weight that can be transported from crossing 11 to crossing nn. Print a blank line between consecutive scenarios.