Battlefield
Time limit5sMemory limit512 MB
Compute the fewest new roads needed so one closed tour can traverse every road exactly once.
Problem
A battlefield is made of cities and bidirectional roads. You want to pick any city you like, start there, travel every road exactly once, and finish back at .
If no such trip exists, you build new roads. A new road also has to be travelled exactly once during the trip. Find the smallest number of new roads that makes the trip possible.
Several roads may connect the same pair of cities. You may build a new road between any two different cities, whether or not a road already connects them. A city that no road touches does not have to be visited.
Input
The first line contains the number of test cases . test cases follow, each in this form.
- One line with the number of cities .
- One line with the number of roads .
- lines, one per road. Each line has two integers and separated by one space, the two endpoints of that road. and are different and satisfy .
Limits
Output
For each test case, print one line with Case #x: followed by the smallest number of new roads. is the number of the test case.