#include<iostream>usingnamespace std;constint MAXN =1005;int t, n, m;int fa[MAXN];voidinit(){for(int i =1; i <= n; i++){
fa[i]= i;}}intget(int x){if(x == fa[x])return x;//路径压缩return fa[x]=get(fa[x]);}voidmerge(int x,int y){
fa[get(x)]=get(y);}intmain(){
cin >> t;while(t--){
cin >> n >> m;init();for(int i =1; i <= m; i++){int a, b;
cin >> a >> b;merge(a, b);}int ans =0;for(int i =1; i <= n; i++){if(fa[i]== i) ans++;}
cout << ans << endl;}}
#include<iostream>#include<cstdio>#include<algorithm>usingnamespace std;constint maxn =1e7+5;int fa[maxn];int size[maxn];int ans;voidinit(){for(int i =1; i <=1e7; i++){
fa[i]= i;//size数组集合大小
size[i]=1;}}intget(int x){if(x == fa[x])return x;return fa[x]=get(fa[x]);}voidmerge(int x,int y){
x =get(x);
y =get(y);//注意x和y要不等if(x != y){
fa[x]= y;//x集合并到y上,y集合大小要加上x集合大小
size[y]+= size[x];}}intmain(){int n;while(~scanf("%d",&n)){init();
ans =0;for(int i =1; i <= n; i++){int a, b;scanf("%d%d",&a,&b);merge(a, b);}for(int i =1; i <=1e7; i++){if(size[i]> ans){
ans = size[i];}}printf("%d\n", ans);}}