#include #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair P; int n,m; int par[10001]; int rank[10001]; int cnt[10001]; int find(int x){ if(x==par[x])return x; return par[x]=find(par[x]); } void unite(int x,int y){ x=find(x); y=find(y); if(x==y)return; if(cnt[x]>cnt[y] || (cnt[x]==cnt[y] && x