struct edge{
int u,v,value;
bool operator < (const edge &t){
return value<t.value;
}
}e[maxn];
int fath[maxn];
int find(int x){
return x == fath[x] ? x : fath[x] = find(fath[x]);
}
int Kruskal(){
int ans=0;
for(int i = 1; i <= n; i++)fath[i] = i;
sort(e+1,e+m+1);
for(int i = 1; i <= m; i++){
int fx = find(e[i].u);
int fy = find(e[i].v);
if(fx != fy){
fath[fy] = fx;
ans+=e[i].value;
}
}
return ans;
}