intmain(intargc,charconst*argv[]){intap;while(scanf("%d",&ap)!=EOF){for(intkk=0;kk<ap;kk++){intt,p;scanf("%d %d",&p,&t);vector<vector<int>>pt(p,vector<int>(t));vector<vector<int>>pp(p);stringline;getline(cin,line);while(getline(cin,line)){if(line==""){break;}istringstreamstream(line);intip,it;stream>>ip>>it;pt[ip-1][it-1]=1;pp[ip-1].push_back(it-1);}vector<int>u(p);intcount=0;for(inti=0;i<p;i++){if(u[i]){continue;}u[i]=1;boolyy;for(intj=i+1;j<p;j++){if(u[j]){continue;}for(vector<int>::iteratorit=pp[i].begin();it!=pp[i].end();it++){yy=pt[i][*it]&pt[j][*it];if(!yy){//printf("%d %d not hit \n",i+1,j+1);break;}}if(yy){//printf("%d %d hit \n",i+1,j+1);u[j]=1;}}count++;}printf("%d\n",count);if(kk!=ap-1){printf("\n");}}}return0;}