#include <bits/stdc++.h>
using namespace std;
struct SegTree {
vector<int> node, lazy;
SegTree(int n) : node(n << 1), lazy(n << 1) {}
void update(int i, int l, int r, int a, int b, int v) {
if (l > b || r < a) {
return;
} else if (l >= a && r <= b) {
return flip(i, v);
}
int m = (l + r) >> 1;
int x = i + 1;
int y = i + ((m - l + 1) << 1);
propagate(i, x, y);
update(x, l, m + 0, a, b, v);
update(y, m + 1, r, a, b, v);
node[i] = node[x] ^ node[y];
}
void flip(int i, int v) {
node[i] ^= v;
lazy[i] ^= v;
}
void propagate(int i, int x, int y) {
flip(x, lazy[i]);
flip(y, lazy[i]);
lazy[i] = 0;
}
int query(int i, int l, int r, int a, int b) {
if (l > b || r < a) {
return 0;
} else if (l >= a && r <= b) {
return node[i];
}
int m = (l + r) >> 1;
int x = i + 1;
int y = i + ((m - l + 1) << 1);
propagate(i, x, y);
return query(x, l, m + 0, a, b) ^ query(y, m + 1, r, a, b);
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n;
vector<vector<int>> adj(n);
for (int i = 1; i < n; ++i) {
int u, v;
cin >> u >> v;
--u, --v;
adj[u].push_back(v);
adj[v].push_back(u);
}
int timer = -1;
vector<int> in(n), out(n);
function<void(int, int)> dfs = [&](int u, int p) {
in[u] = ++timer;
for (int v : adj[u]) {
if (v != p) {
dfs(v, u);
}
}
out[u] = ++timer;
};
dfs(0, -1);
SegTree tree(out[0] + 1);
cin >> q;
while (q--) {
int t;
cin >> t;
if (t == 1) {
int u, v;
cin >> u >> v;
--u;
tree.update(0, in[0], out[0], in[u], out[u], v);
} else {
int u;
cin >> u;
--u;
cout << tree.query(0, in[0], out[0], in[0], in[u]) << "\n";
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3QgU2VnVHJlZSB7CiAgdmVjdG9yPGludD4gbm9kZSwgbGF6eTsKICAKICBTZWdUcmVlKGludCBuKSA6IG5vZGUobiA8PCAxKSwgbGF6eShuIDw8IDEpIHt9CiAgCiAgdm9pZCB1cGRhdGUoaW50IGksIGludCBsLCBpbnQgciwgaW50IGEsIGludCBiLCBpbnQgdikgewogICAgaWYgKGwgPiBiIHx8IHIgPCBhKSB7CiAgICAgIHJldHVybjsKICAgIH0gZWxzZSBpZiAobCA+PSBhICYmIHIgPD0gYikgewogICAgICByZXR1cm4gZmxpcChpLCB2KTsKICAgIH0KICAgIGludCBtID0gKGwgKyByKSA+PiAxOwogICAgaW50IHggPSBpICsgMTsKICAgIGludCB5ID0gaSArICgobSAtIGwgKyAxKSA8PCAxKTsKICAgIHByb3BhZ2F0ZShpLCB4LCB5KTsKICAgIHVwZGF0ZSh4LCBsLCBtICsgMCwgYSwgYiwgdik7CiAgICB1cGRhdGUoeSwgbSArIDEsIHIsIGEsIGIsIHYpOwogICAgbm9kZVtpXSA9IG5vZGVbeF0gXiBub2RlW3ldOwogIH0KICAKICB2b2lkIGZsaXAoaW50IGksIGludCB2KSB7CiAgICBub2RlW2ldIF49IHY7CiAgICBsYXp5W2ldIF49IHY7CiAgfQogIAogIHZvaWQgcHJvcGFnYXRlKGludCBpLCBpbnQgeCwgaW50IHkpIHsKICAgIGZsaXAoeCwgbGF6eVtpXSk7CiAgICBmbGlwKHksIGxhenlbaV0pOwogICAgbGF6eVtpXSA9IDA7CiAgfQogIAogIGludCBxdWVyeShpbnQgaSwgaW50IGwsIGludCByLCBpbnQgYSwgaW50IGIpIHsKICAgIGlmIChsID4gYiB8fCByIDwgYSkgewogICAgICByZXR1cm4gMDsKICAgIH0gZWxzZSBpZiAobCA+PSBhICYmIHIgPD0gYikgewogICAgICByZXR1cm4gbm9kZVtpXTsKICAgIH0KICAgIGludCBtID0gKGwgKyByKSA+PiAxOwogICAgaW50IHggPSBpICsgMTsKICAgIGludCB5ID0gaSArICgobSAtIGwgKyAxKSA8PCAxKTsKICAgIHByb3BhZ2F0ZShpLCB4LCB5KTsKICAgIHJldHVybiBxdWVyeSh4LCBsLCBtICsgMCwgYSwgYikgXiBxdWVyeSh5LCBtICsgMSwgciwgYSwgYik7CiAgfQp9OwoKaW50IG1haW4oKSB7CiAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogIGNpbi50aWUoMCk7CiAgaW50IG4sIHE7CiAgY2luID4+IG47CiAgdmVjdG9yPHZlY3RvcjxpbnQ+PiBhZGoobik7CiAgZm9yIChpbnQgaSA9IDE7IGkgPCBuOyArK2kpIHsKICAgIGludCB1LCB2OwogICAgY2luID4+IHUgPj4gdjsKICAgIC0tdSwgLS12OwogICAgYWRqW3VdLnB1c2hfYmFjayh2KTsKICAgIGFkalt2XS5wdXNoX2JhY2sodSk7CiAgfQogIGludCB0aW1lciA9IC0xOwogIHZlY3RvcjxpbnQ+IGluKG4pLCBvdXQobik7CiAgZnVuY3Rpb248dm9pZChpbnQsIGludCk+IGRmcyA9IFsmXShpbnQgdSwgaW50IHApIHsKICAgIGluW3VdID0gKyt0aW1lcjsKICAgIGZvciAoaW50IHYgOiBhZGpbdV0pIHsKICAgICAgaWYgKHYgIT0gcCkgewogICAgICAgIGRmcyh2LCB1KTsKICAgICAgfQogICAgfQogICAgb3V0W3VdID0gKyt0aW1lcjsKICB9OwogIGRmcygwLCAtMSk7CiAgU2VnVHJlZSB0cmVlKG91dFswXSArIDEpOwogIGNpbiA+PiBxOwogIHdoaWxlIChxLS0pIHsKICAgIGludCB0OwogICAgY2luID4+IHQ7CiAgICBpZiAodCA9PSAxKSB7CiAgICAgIGludCB1LCB2OwogICAgICBjaW4gPj4gdSA+PiB2OwogICAgICAtLXU7CiAgICAgIHRyZWUudXBkYXRlKDAsIGluWzBdLCBvdXRbMF0sIGluW3VdLCBvdXRbdV0sIHYpOwogICAgfSBlbHNlIHsKICAgICAgaW50IHU7CiAgICAgIGNpbiA+PiB1OwogICAgICAtLXU7CiAgICAgIGNvdXQgPDwgdHJlZS5xdWVyeSgwLCBpblswXSwgb3V0WzBdLCBpblswXSwgaW5bdV0pIDw8ICJcbiI7CiAgICB9CiAgfQogIHJldHVybiAwOwp9Cg==