#include #include #include #include #define N 100005 #define MS(a,b) memset(a,b,sizeof(a)) #define maxn 0x7fffffff using namespace std; int fa[4000]; int findx(int x) { if(fa[x]!=x) fa[x]=findx(fa[x]); return fa[x]; } void Union(int x,int y) { int tx,ty; tx=findx(x);ty=findx(y); if(tx!=ty) fa[tx]=ty; } int main() { int n,m,i,j,a,b,w[N],ans[4000],sum,s; while(~scanf("%d %d",&n,&m)) { for(i=1;i<=n;i++) fa[i]=i; MS(ans,0); for(i=0;i