#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } template struct LazySegmentTree{ using F=function; using G=function; using H=function; int sz,height; vector data; vector lazy; const F f; const G g; const H h; const Monoid M1; const OperatorMonoid OM0; LazySegmentTree(int n,const F f,const G g,const H h,const Monoid &M1,const OperatorMonoid OM0) : f(f),g(g),h(h),M1(M1),OM0(OM0) { sz=1;height=0; while(sz0;k--) data[k]=f(data[2*k+0],data[2*k+1]);} inline void propagate(int k){ if(lazy[k]!=OM0){ lazy[2*k+0]=h(lazy[2*k+0],lazy[k]); lazy[2*k+1]=h(lazy[2*k+1],lazy[k]); data[k]=reflect(k); lazy[k]=OM0; } } inline Monoid reflect(int k){ return lazy[k]==OM0?data[k]:g(data[k],lazy[k]); } inline void recalc(int k){ while(k>>=1)data[k]=f(reflect(2*k+0),reflect(2*k+1)); } inline void thrust(int k){ for(int i=height;i>0;i--) propagate(k>>i); } void update(int a,int b,const OperatorMonoid &x){ if(a>=b) return ; thrust(a+=sz);thrust(b+=sz-1); for(int l=a,r=b+1;l>=1,r>>=1){ if(l&1) lazy[l]=h(lazy[l],x),l++; if(r&1) --r,lazy[r]=h(lazy[r],x); } recalc(a);recalc(b); } Monoid query(int a,int b){ thrust(a+=sz);thrust(b+=sz-1); Monoid L=M1,R=M1; for(int l=a,r=b+1;l>=1,r>>=1){ if(l&1) L=f(L,reflect(l++)); if(r&1) R=f(reflect(--r),R); } return f(L,R); } Monoid operator[](const int &k){ return query(k,k+1); } }; signed main(){ int n;cin>>n; using P=pair; vector> g(n); rep(i,n-1){ int u,v;ll w;cin>>u>>v>>w; g[u].emplace_back(v,w); } vector l(n),r(n); vector et; vector x,y; int pos=0; function dfs=[&](int cur){ l[cur]=pos++; et.push_back(cur); for(auto [to,c]:g[cur]){ x.push_back(c); y.push_back(1); dfs(to); x.push_back(c); y.push_back(-1); } r[cur]=pos++; }; dfs(0); struct segnode{ ll val,pos,neg; segnode(ll val,ll pos,ll neg):val(val),pos(pos),neg(neg){} }; auto segf=[&](segnode lhs,segnode rhs){ return segnode(lhs.val+rhs.val,lhs.pos+rhs.pos,lhs.neg+rhs.neg); }; auto segg=[&](segnode mugen,ll ad){ return segnode(mugen.val+ad*mugen.pos-ad*mugen.neg,mugen.pos,mugen.neg); }; auto segh=[&](ll cur,ll add){ return cur+add; }; LazySegmentTree seg(x.size(),segf,segg,segh,segnode(0,0,0),0); rep(i,(int)x.size()){ seg.set(i,segnode(x[i]*y[i],(y[i]==1),(y[i]==-1))); } seg.build(); int q;cin>>q; while(q--){ int type;cin>>type; if(type==1){ int v;ll ad;cin>>v>>ad; seg.update(l[v],r[v]-1,ad); }else{ int b;cin>>b; cout<