Ronju is a night-guard at the "Lavish office buildings Ltd." headquarters. The office has a large grass field in front of the building. Every day, when Ronju comes to duty in the evening, it is his duty to turn on all the lights in the field. However, given the large size of the field and a large number of lights, it is very tiring for him to walk to each light to turn it on.
After a lot of thinking, he has devised an ingenious plan - he will swap the switches for light-sensitive triggers. A local electronic store nearby sells these funny trigger switches at a very cheap price. Once installed at a light-post, it will automatically turn that light on whenever it can sense some other light lighting up nearby. So, from now on, Ronju can just manually flip a few switches, and the light from those will trigger nearby sensors, which will in turn light up some more lights nearby, and so on, gradually lighting up the whole field.
Now Ronju wonders: how many switches does he have to flip manually for this?
Input
Input starts with an integer T (≤ 10),denoting the number of test cases.
Each case contains a blank line two integers N (1 ≤ N ≤ 10000) and M (0 ≤ M ≤ 50000), where N is the number of lights in the field, and M more lines of input follows in this input case. Each of these extra M lines will have two different integers a and b separated by a space, where 1 ≤ a, b≤ N, indicating that if the light a lights up, it will trigger the light b to turn on as well (according to their distance, brightness, sensor sensitivity, orientation and other complicated factors).
Output
For each case, print the case number and the minimum number of lights that Ronju must turn on manually before all the lights in the whole field gets lit up.
Sample
Sample Input | Sample Output |
---|---|
2 5 4 1 2 1 3 3 4 5 3 4 4 1 2 1 3 4 2 4 3 | Case 1: 2 Case 2: 2 |