#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 1000000000 struct unionfind{ vector data; vector size; unionfind(int n){ for(int i=0;isize[y])swap(x,y); data[x]=y; size[y]+=size[x]; return true; } bool check(int x,int y){ return (find(x)==find(y)); } int get_size(int x){ int X = find(x); return size[X]; } }; int beki(long long a,long long b,int M = modulo){ int x = 1; while(b!=0){ if(b&1){ x=((long long)x*a)%M; } a=((long long)a*a)%M; b>>=1; } return x; } int gyakugen(int a){ return beki(a,modulo-2); } int N,M,X; int ans = 0; int dfs(auto &E,int now,int p){ int ret = 0; for(int i=0;i>N>>M>>X; vector>> E(N,vector>()); unionfind uf(N); for(int i=0;i>x>>y>>z; x--;y--; if(uf.unite(x,y)){ E[x].emplace_back(y,z); E[y].emplace_back(x,z); } } dfs(E,0,-1); cout<