// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ ███████████████████ // #include "bits/stdc++.h" using namespace std; #define MOD 1000000007 //#define MOD 998244353 const double EPS = 1e-9; #define INF (1LL<<60) #define D double #define fs first #define sc second #define int long long #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i) #define REP(i,n) FOR(i,0,(n)) #define RREP(i,n) RFOR(i,0,(n)) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i,a,b) ((a)<=(i) && (i)<(b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair P; typedef vector vec; typedef vector> mat; template struct SegmentTree{ using F = function; using G = function; using H = function; int n; F f; G g; H h; T ti; E ei; vector dat; vector laz; SegmentTree(F f,G g,H h,T ti,E ei): f(f),g(g),h(h),ti(ti),ei(ei){} void init(int n_){ n=1; while(n &v){ int n_=v.size(); init(n_); for(int i=0;i=0;i--) dat[i]=f(dat[(i<<1)+2],dat[(i<<1)|1]); } void eval(int k,int l,int r){ if(laz[k]==ei)return; dat[k] = g(dat[k], laz[k], r-l); if(r-l>1){ laz[(k<<1)|1] = h(laz[(k<<1)|1], laz[k]); laz[(k<<1)+2] = h(laz[(k<<1)+2], laz[k]); } laz[k]=ei; } void update(int a, int b, E x,int k=0,int l=0,int r=-1){ if(r<0)r=n; eval(k,l,r); if(r<=a||b<=l)return; if(a<=l&&r<=b){ laz[k] = h(laz[k], x); eval(k,l,r); } else { update(a,b,x,(k<<1)|1,l,(l+r)/2); update(a,b,x,(k<<1)+2,(l+r)/2,r); dat[k]=f(dat[(k<<1)|1], dat[(k<<1)+2]); } } T query(int a,int b,int k=0,int l=0,int r=-1){ if(r<0)r=n; eval(k,l,r); if(r<=a||b<=l)return ti; if(a<=l&&r<=b)return dat[k]; T xl=query(a,b,(k<<1)|1,l,(l+r)/2); T xr=query(a,b,(k<<1)+2,(l+r)/2,r); return f(xl, xr); } //lower_find(l,r,fanc): fancを満たす区間[0,id)なるidの最小値を返す. ng < okのとき template int lower_find(int a, int b, C &check, T x, int k=1, int l=0, int r=-1){ if(r<0)r=n; if(!check(f(x,dat[k]))||r<=a||b<=l)return -1; if(r-l==1)return l; int xl = lower_find(a,b,check,x,(k<<1),l,(l+r)/2); if(xl>=0)return xl; x = f(x,dat[(k<<1)]); return lower_find(a,b,check,x,(k<<1)|1,(l+r)/2,r); } template int lower_find(int a, int b, C &check){ T x=ti; return lower_find(a,b,check,x); } //upper_find(l,r,fanc): fancを満たす区間[0,id)なるidの最小値を返す. ok < ngのとき template int upper_find(int a, int b, C &check, T x, int k=2, int l=0, int r=-1){ if(r<0)r=n; if(r<=a||b<=l)return -1; if(r-l==1)return l; if(check(f(x,dat[k]))){ int xr = upper_find(a,b,check,f(x,dat[k]),((k+1)<<1),(l+r)/2,r); if(xr>=0)return xr; } return upper_find(a,b,check,x,(k<<1),l,(l+r)/2); } template int upper_find(int a, int b, C &check){ T x=ti; return upper_find(a,b,check,x); } }; //ex) RAQ & RSQ //auto f = [](int a, int b){return a+b;}; //auto g = [](int a, int b, int len){return a+b*len;}; //auto h = [](int a, int b){return a+b;}; //ex) RAQ & RMQ //auto f = [](int a, int b){return min(a,b);}; //auto g = [](int a, int b, int len){return a+b;}; //auto h = [](int a, int b){return a+b;}; const int N = 1e5+10; vector

edge[N],path; vector l(N),r(N); void dfs(int no, int par){ l[no] = path.size(); for(P to: edge[no]){ if(to.fs==par) continue; path.emplace_back(to.sc,1); dfs(to.fs,no); path.emplace_back(-to.sc,-1); } r[no] = path.size(); } signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; REP(_,n-1){ int x,y,c; cin >> x >> y >> c; edge[x].emplace_back(y,c); edge[y].emplace_back(x,c); } dfs(0,-1); //REP(i,n) cout << l[i] SP r[i] << endl; auto f = [](P a, P b){return P(a.fs+b.fs,a.sc+b.sc);}; auto g = [](P a, int b, int len){return P(a.fs+b*a.sc,a.sc);}; auto h = [](int a, int b){return a+b;}; SegmentTree seg(f,g,h,P(0,0),0); seg.build(path); //REP(i,path.size()) cout << path[i].fs SP path[i].sc << endl; int q; cin >> q; REP(_,q){ int k; cin >> k; if(k==1){ int a,x; cin >> a >> x; seg.update(l[a],r[a],x); } else{ int b; cin >> b; cout << seg.query(0,l[b]).fs << "\n"; } } return 0; }