文理学院程序设计在线练习


Kill time

Time Limit: 1 Second(s)    Memory Limit: 32 MB

Total Submission(s): 46   Accepted Submission(s): 8
Problem Description

Mr.Bluefly feels very boring on the slow moving Green Train. So he starts playing a puzzle game on his new iphone6+. In 5 minutes, however, he falls asleep. This game seems too hard for him. The game’s goal is to eliminate fragments. Two designated fragments can be eliminated through combination. So here is the question: Can you help him finish this game with top score (to minimize the amount of fragments left)? Or he will go mad when he gets up.

Input

An integer T in the first line, then follows T groups of test data.
In each data group, two integers n and m in the first line indicates that there are n fragments(No.1 to No.n) and m relations. Then m lines and two numbers each line. The a[i] and b[i] in line i indicates that the fragment a[i] and b[i] can be eliminated through combination.
(0<=N<=500,0<=M<=1000)

Output

Each line an integer of the minimum amount of the fragments left in each group of test data.

Sample Input
1
6 3
1 2
3 2
3 4
Sample Output
2
Source

2014市赛