#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; template<typename F> struct FixPoint : F{ FixPoint(F&& f):F(forward<F>(f)){} template<typename... Args> decltype(auto) operator()(Args&&... args) const{ return F::operator()(*this,forward<Args>(args)...); } }; template<typename F> inline decltype(auto) MFP(F&& f){ return FixPoint<F>{forward<F>(f)}; } //INSERT ABOVE HERE signed main(){ Int n; cin>>n; vector< map<Int, Int> > G(n); for(Int i=1;i<n;i++){ Int u,v,w; cin>>u>>v>>w; G[u][v]=w; G[v][u]=w; } Int q; cin>>q; for(Int i=0;i<q;i++){ Int t; cin>>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<Int> xs(k); for(Int j=0;j<k;j++) cin>>xs[j]; vector<Int> 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<<dp[xs[0]]<<"\n"; } } cout<<flush; return 0; }