Military Recruit

No attempts yetTime limit1sMemory limit128 MB

Problem

Tom is a recruit for an elite army unit. As the final part of his exams, he will be dropped into unknown terrain and must march to a designated exit point while carrying all of his heavy gear.

Because he is a little nervous, Tom has studied satellite images of the training area. He has identified every possible entry and exit site, together with the possible connections between sites and their estimated lengths. Because of differences in terrain height these connections are one-directional: the length from one site to another need not equal the length in the opposite direction, so the length from site ii to jj may differ from the length from jj to ii.

Tom does not know in advance which site will be his start and which will be his exit. He realises that, no matter how hard he trains, he cannot possibly succeed in the worst case — the pair of sites that are farthest apart.

His instructors always choose two distinct sites as the entry and exit, and Tom assumes that every ordered pair of distinct (entry,exit)(\text{entry}, \text{exit}) sites is equally likely. For a given pair, the distance he must march is the length of the shortest path from the entry site to the exit site.

Given the sites, the direct connections and their lengths, and Tom's desired success probability pp, compute the minimum distance DD that he must be comfortable with so that he passes with probability at least p%p\%. In other words, DD is the smallest value for which the fraction of ordered (entry,exit)(\text{entry}, \text{exit}) pairs whose shortest-path length is at most DD is at least p/100p / 100.

Input

The first line contains the number of scenarios.

Each scenario is given as follows. The first line contains an integer pp (1p1001 \le p \le 100), Tom's minimum success probability as a percentage. The next line contains the number of sites nn (2n1002 \le n \le 100). Each of the following nn lines contains nn integers separated by spaces: the jj-th integer on the ii-th line is the length of the direct connection from site ii to site jj.

Every distance is a non-negative integer less than 10001000. The distance from a site to itself is always 00. A value of 1-1 means there is no direct connection in that direction. You may assume that every site is reachable from every other site.

Output

For each scenario, first print a line Scenario #i:, where ii is the scenario number starting at 11. On the next line, print the minimum distance DD that Tom must be prepared for. Separate consecutive scenarios with a single blank line.