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


How Many Tables

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

Total Submission(s): 338   Accepted Submission(s): 177
Problem Description

今天是小Z的生日,他邀请了许多朋友参加聚会,由于有些朋友之间互不认识,这些互不认识的人不愿意坐在同一张桌上,但是如果A认识B,且B认识C,那么A和C就算是认识的。
请你帮小Z算一下,至少需要多少张桌子,才能满足要求。

Input

输入数据首先包含一个整数T,表示测试实例的个数,然后是T组测试数据。
Each test case starts with two integers N and M(1<=N,M<=1000). N indicates the number of friends, the friends are marked from 1 to N. Then M lines follow. Each line consists of two integers A and B(A!=B), that means friend A and friend B know each other.

Output

对每组测试数据,输出至少需要多少张桌子。

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

Hdoj