#include using namespace std; using ll = long long; vector visited(200000, false); vector parent(200000, -1); vector>> g(200000); void dfs(int p, vector& f){ if(visited[p]) return; visited[p] = true; for(auto v : g[p]){ if(visited[v.first]) continue; parent[v.first] = p; dfs(v.first, f); f[p] ^= f[v.first]; f[p] ^= v.second; } } 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}); } vector f(n, 0); dfs(0, f); queue anslist; int q; cin >> q; for(int i = 0; i < q; i++){ int t, x, y; cin >> t >> x >> y; if(t == 1){ x--, y--; f[parent[x]] ^= f[x]; f[y] ^= f[x]; parent[x] = y; }else{ anslist.push(f[x - 1]); } } while(!anslist.empty()){ cout << anslist.front() << endl; anslist.pop(); } return 0; }