#include #include using namespace std; using ll = long long; using S = pair; using F = ll; S e(){return make_pair(0, 0);} S op(S l,S r){return make_pair(l.first + r.first, l.second + r.second);} S mapping(F f, S x){return make_pair(x.first + x.second * f, x.second);} F composition(F f, F g){return f + g;} F id(){return 0;} int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, u, v, w, Q; cin >> n; vector>> g(n); for(int i = 1; i < n; i++){ cin >> u >> v >> w; g[u].emplace_back(v, w); g[v].emplace_back(u, w); } int timer = 0; vector depth(n), ent(n), ext(n), weight(n); vector> tmp(2 * n); function dfs = [&](int v, int p){ tmp[timer] = make_pair(weight[v], 1); ent[v] = timer++; for(auto &&pa : g[v]){ tie(u, w) = pa; if(u == p) continue; depth[u] = depth[v] + 1; weight[u] = w; dfs(u, v); } tmp[timer] = make_pair(-weight[v], -1); ext[v] = timer++; }; dfs(0, -1); atcoder::lazy_segtree seg(tmp); cin >> Q; while(Q--){ int cmd, v, x; cin >> cmd >> v; if(cmd == 1){ cin >> x; seg.apply(ent[v] + 1, ext[v], x); }else{ cout << seg.prod(0, ent[v] + 1).first << '\n'; } } }