#include using namespace std; const int N=500; vector> graph[N]; vector mst[N]; int vis[N]; int min_edge; int Prims(int src,int min_edge) { int cost=0; priority_queue,vector>,greater>>pq; pq.push({0,src}); while(!pq.empty()) { pair p=pq.top(); pq.pop(); int u=p.second; int wt=p.first; if(!vis[u]) { for(auto child:graph[u]) { if(child.first<=min_edge) pq.push({child}); } vis[u]=1; cost+=wt; } } return cost; } int main() { int v,e; cin>>v>>e; for(int i=1; i<=e; i++) { int x,y,wt; cin>>x>>y>>wt; graph[x].push_back({wt,y}); graph[y].push_back({wt,x}); } cin>>min_edge; int ans=0,component=0; for(int i=1; i<=v; i++) { if(!vis[i]) { component++; ans+=Prims(i,min_edge); } } cout<