Problems
A modern railroad system built in Ekiya's town bumped into a major hurdle: the main freeway
running north to south.
Ekiya is assessing which stations would be most convenient to connect with the overpass. As part of that assessment, she wants to know how the average length (in number of stations) of a path within the system might change with each possible option.
A path between stations
A complete map is a map that has
As an example, the picture below illustrates a scenario with
This table shows the lengths of the paths between pairs of stations if each overpass were to be built.
| West | West | ||
| West | East | ||
| West | East | ||
| West | East | ||
| West | East | ||
| West | East | ||
| West | East | ||
| East | East | ||
| East | East | ||
| East | East | ||
| Average: |
Given the current stations and connections, and a list of options for the overpass connection, help Ekiya by calculating the average distance of the map that would result if that option was the only overpass connection built.
Input
The first line of the input gives the number of test cases,
The second line of a test case contains
The third line of a test case contains
Finally, the last
Output
For each test case, output one line containing
Case #,
where
, , and will be considered correct if they are within an
absolute or relative error of
Example
3
2 3 2
2
3 3
1 1
2 3
3 4 2
2 3
3 3 4
1 3
1 2
3 4 1
2 3
3 3 4
2 2
Case #1: 2.0 1.8
Case #2: 2.19047619 2.47619048
Case #3: 2.2857142857