#include using namespace std; #include using namespace atcoder; using ll = long long; // Euler Tour vector vis; vector edges(1, 0); vector>> g(50000); vector in(50000); vector out(50000); vector seen(50000, false); int t = 0; void dfs(int p){ in[p] = t; t++; vis.push_back(p); seen[p] = true; for(auto v : g[p]){ if(seen[v.first]) continue; edges.push_back(v.second); dfs(v.first); vis.push_back(p); edges.push_back(0); } t++; out[p] = t; } // lazy segtree ll ID = 8000000000000000000; ll op(ll a, ll b){ return a ^ b; } ll e(){ return 0; } ll mapping(ll f, ll x){ if(f == ID){ return x; }else{ return f; } } ll composition(ll f, ll g){ if(f == ID){ return g; }else{ return f; } } ll id(){ return ID; } // main int main(){ int n; cin >> n; for(int i = 0; i < n - 1; i++){ int l, r; cin >> l >> r; ll a; cin >> a; g[l - 1].push_back({r - 1, a}); g[r - 1].push_back({l - 1, a}); } vis.reserve(n * 2); edges.reserve(n * 2); dfs(0); edges.push_back(0); int m = vis.size(); lazy_segtree seg(edges); int q; cin >> q; for(int i = 0; i < q; i++){ int t; cin >> t; int x; cin >> x; x--; if(t == 1){ // delete seg.apply(in[x], out[x], 0); }else{ // f(x) cout << seg.prod(in[x] + 1, out[x]) << endl; } } }