#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 FixPoint : F{ FixPoint(F&& f):F(forward(f)){} template decltype(auto) operator()(Args&&... args) const{ return F::operator()(*this,forward(args)...); } }; template inline decltype(auto) MFP(F&& f){ return FixPoint{forward(f)}; } //INSERT ABOVE HERE signed main(){ Int n; cin>>n; vector< map > G(n); for(Int i=1;i>u>>v>>w; G[u][v]=w; G[v][u]=w; } Int q; cin>>q; for(Int i=0;i>t; if(t==1){ Int u,v,w,x; cin>>u>>v>>w>>x; G[u].erase(v); G[v].erase(u); G[v][w]=x; G[w][v]=x; } if(t==2){ Int k; cin>>k; vector xs(k); for(Int j=0;j>xs[j]; vector dp(n,-1); for(Int x:xs) dp[x]=0; MFP([&](auto dfs,Int v,Int p)->void{ for(auto e:G[v]){ Int u=e.first,c=e.second; if(u==p) continue; dfs(u,v); if(dp[u]<0) continue; if(dp[v]<0) dp[v]=0; dp[v]+=dp[u]+c; } })(xs[0],-1); cout<