#include int find(int n,int p[]){ if(p[n]==n)return n; return p[n]=find(p[n],p); } int main(){ int p[1000],n,m,l,r,ans=-1; scanf("%d%d",&n,&m); for(int i=0;ir)p[l]=r; else p[r]=l; } for(int i=0;i