Server Time: Tue Nov 19, 2019 10:29 am
Welcome ( logout
1034 - Hit the Light Switches
  PDF (English) Statistics Forum
Time Limit: 2 second(s) Memory Limit: 32 MB

Ronju is a night-guard at the "Lavish office buildings Ltd." headquarters. The office has a large grass field in front of the building. So every day, when Ronju comes to duty at the evening, it is his duty to turn on all the lights in the field. However, given the large size of the field and the large number of lights, it is very tiring for him to walk to each and every individual light to turn it on.

So 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 (≤ 15), denoting the number of test cases.

Each case contains a blank line two integers N (1 ≤ N ≤ 10000) and M (0 ≤ M ≤ 105), 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 minimum number of lights that Ronju must turn on manually before all the lights in the whole field gets lit up.

Sample Input

Output for Sample Input

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

 


Problem Setter: Samee Zahur
Special Thanks: Jane Alam Jan
Developed and Maintained by
JANE ALAM JAN
Copyright © 2012
LightOJ, Jane Alam Jan