Cable Cleanup
Time limit1sMemory limit256 MB
For each test case, keep N minus 1 of the M cables that join N computers into one network and print how many cables go.
Problem
At an ICPC regional contest, the operations team arrived at the site and only then found that the network of the contestant computers had been wired incorrectly. A large number of unneeded cables had been installed between the computers.
Abdelrahman, the director of operations, wants to remove as many cables as he can so that a runner is less likely to trip over one. Every computer still has to be reachable from every other computer after the removal. In the initial state all computers are reachable from each other.
Two computers are reachable from each other if a cable connects them directly. They are also reachable from each other if both of them are reachable from some third computer.
Find the maximum number of cables that can be removed.
Input
The first line contains the number of test cases , where .
Each of the following lines holds one test case: two integers and separated by a single space, where is the number of computers in the contest hall and is the number of cables. The bounds are and .
The input does not say which computers each cable connects. It only guarantees that in the initial state all computers are reachable from each other.
Output
For each test case, print one line in the form Case n: R. Here is the test case number starting from 1, and is the maximum number of cables that can be removed.