#include namespace { #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using ull = unsigned long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; constexpr int MX = 100000; vector> g[MX]; int in_time[MX], out_time[MX]; ull a_par[MX]; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; rep(i, n - 1) { int l, r; ull a; cin >> l >> r >> a; l--; r--; g[l].emplace_back(r, a); g[r].emplace_back(l, a); } int time = 0; auto dfs = [&](auto self, int u, int p) -> void { in_time[u] = time; time++; for(auto [v, a] : g[u]) { if (v != p) { a_par[time] = a; self(self, v, u); } } out_time[u] = time; }; dfs(dfs, 0, -1); int q; cin >> q; rep(_, q) { int t, x; cin >> t >> x; x--; if (t == 1) { int l = in_time[x], r = out_time[x]; memset(&a_par[l], 0, sizeof(ull) * (r - l)); } else { ull ans = 0; int l = in_time[x] + 1, r = out_time[x]; assert(0 <= l && l <= r && r <= MX); for(int i = l; i < r; i++) ans ^= a_par[i]; cout << ans << '\n'; } } }