QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 33

#14012. Battlefield

Statistics

You are playing a game where the battlefield consists of N cities and R bidirectional roads. Your goal is to start at some city C of your choice and visit all R roads exactly once ending this trip at C. If this is not possible you must add the minimum number of additional roads to the initial set of roads to make this trip feasible. Please note that there might be more than one road connecting the same pair of cities and that you are allowed to add roads between any pair of cities regardless of whether they already had roads connecting them or not as shown in the sample input/output.

Input

The first line of input gives the number of test cases, T. T test cases follow. For each test case there will be:

  • One line containing the value N, the number of cities.
  • One line containing the value R, the number of roads.
  • R lines corresponding to the roads. Each contains 2 values A and B separated by one space. A and B are 2 distinct integers (0 ≤ A,B < N) indicating the end points of that road.

Limits

  • 1 ≤ T ≤ 30
  • 2 ≤ N ≤ 1000

Small Dataset (12 points)

  • 1 ≤ R ≤ 15

Small Dataset (21 points)

  • 1 ≤ R ≤ 104

Output

For each test case, output one line containing "Case #x: ", where x is the number of the test case, followed by the minimum number of roads needed.

Example

Input

3
2
2
0 1
0 1
3
3
1 2
1 2
2 1
4
5
0 1
2 0
0 3
1 2
3 1

Output

Case #1: 0
Case #2: 1
Case #3: 1

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.