Problems
Apricot Rules LLC is developing a new simplified networking protocol and wants to show off their
routing algorithm. In their design, a network consists of
Unfortunately, the routing algorithm is too aggressive and will route all traffic from a machine through the highest priority link connected to it. This may make some groups of machines isolated from others.
Formally, we say that a machine
For example, as seen in the left image above, only the links with priorities
As part of the quality assurance team at Apricot Rules LLC, you are investigating the extent
of the problem. You are interested in knowing the probability of there
being exactly
Input
The first line of the input gives the number of test cases,
Output
For each test case, output one line containing Case #,
where
Example
3
5 2
5 1
6 3
Case #1: 428571432
Case #2: 571428576
Case #3: 47619048