#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a struct Kruskal{ struct edge{ Int from,to; T cost; Int used; edge(){} edge(Int from,Int to,T cost): from(from),to(to),cost(cost),used(0){} bool operator<(const edge& e) const{ return cost p,r; vector edges; Kruskal(){} Kruskal(Int n):n(n){} void init(Int n){ r.assign(n,1); p.resize(n); iota(p.begin(),p.end(),0); } Int find(Int x){ return (x==p[x]?x:p[x]=find(p[x])); } bool same(Int x,Int y){ return find(x)==find(y); } void unite(Int x,Int y){ x=find(x);y=find(y); if(x==y) return; if(r[x]>n>>m>>k; vector a(m),b(m),c(m); Int sum=0; for(Int i=0;i>a[i]>>b[i]>>c[i]; a[i]--;b[i]--; sum+=c[i]; } vector e(k); for(Int i=0;i>e[i]; vector u(m); for(Int i=0;i; Kruskal

G(n); for(Int i=0;i