#include "bits/stdc++.h" using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 1000000007; //10^9+7 int par[10002]; int myrank[10002]; void init(int n){ rep(i,1,n+1){ par[i]=i; myrank[i]=0; } } int find(int x){ if(par[x]==x){ return x; }else{ return par[x]=find(par[x]); } } void unit(int x, int y){ x=find(x); y=find(y); par[x]=y; } bool same(int x, int y){ return find(x)==find(y); } int size(int x, int n){ int group=find(x); int size=0; rep(i,1,n+1)if(find(i)==group)size++; return size; } int main(){ int n,m; cin>>n>>m; init(n); rep(i,1,n+1)myrank[i]=i; //print("start"); //rep(i,1,n+1)print(par[i]); REP(i,m){ int a,b; cin>>a>>b; if(same(a,b))continue; int a_size=size(a,n); int b_size=size(b,n); if(a_size==b_size){ if(find(a)>find(b)){ unit(a,b); }else{ unit(b,a); } }else if(a_size