#include #include using namespace std; const int maxn=3005; #define inf 0x3f3f3f3f int pre[maxn]; int sum[maxn]; int n,m; int find(int x) { if(pre[x]==x) return x; return pre[x]=find(pre[x]); } bool merge(int x,int y) { int fx=find(x); int fy=find(y); if(fx!=fy) { pre[fx]=fy; return true; } return false; } int main() { while(~scanf("%d%d",&n,&m)) { int cnt=n-1; memset(sum,0,sizeof(sum)); for(int i=0;isum[i]) minn=sum[i]; cout<