#includeusing namespace std;int f30001,num30001;int find(int x)if(x!=fx)fx=find(fx);return fx;int main()int n,m;while(cinnm)if(n=0for(int i=0;it;cinx;while(fx!=x) x=fx;for(int i=1;iy;while(fy!=y) y=fy;x=find(x);if(xy)fy=x;numx+=numy; else if (y x)fx=y;numy+=numx;/y=x; for(int i=0;i=6;i+)printf(“%d “,fi);printf(“n“); coutnumfind(0)endl; return 0; /*void Union(int x,int y)if(rankxranky)prex=y;elseprey=x;if(rankx=ranky)rankx+;*/