#include using namespace std; using i64 = long long; #define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++) #define all(x) x.begin(),x.end() #define let auto const template struct dynarr: std::vector { using std::vector::vector; using size_type = typename std::vector::size_type; auto&& operator[](size_type i) { return this->at(i); } auto&& operator[](size_type i) const { return this->at(i); } }; int main() { i64 N; cin >> N; vector p(N); vector w(N); vector> G(N); for(int i = 0;i < N - 1;i++) { i64 a, b, c; cin >> a >> b >> c; p[b] = a; w[b] = c; G[a].push_back(b); } i64 Q; cin >> Q; for(int i = 0;i < Q;i++) { i64 type = 0; cin >> type; if(type == 1) { i64 a, x; cin >> a >> x; queue que; que.push(a); while(!que.empty()) { i64 v = que.front(); que.pop(); for(auto to: G[v]) { w[to] += x; que.push(to); } } } else { i64 b; cin >> b; i64 ans = 0; while(b != 0) { ans += w[b]; b = p[b]; } cout << ans << endl; } } }