#include #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 P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; struct HLD { std::vector> &to; int root, n; std::vector sz, parent, depth, idx, ridx, head, inv; HLD(std::vector>& to, int root=0): to(to), root(root), n(to.size()), sz(n), parent(n), depth(n), idx(n), ridx(n), head(n), inv(n) { init_tree_data(root); int x = 0; assign_idx(root, root, x); } void init_tree_data(int u, int p=-1, int d=0) { parent[u] = p; depth[u] = d; int s = 1; for(int v: to[u]) { if (v == p) continue; init_tree_data(v, u, d+1); s += sz[v]; } sz[u] = s; } void assign_idx(int u, int h, int &nxt, int p=-1) { head[u] = h; inv[nxt] = u; idx[u] = nxt++; if (sz[u] == 1) { ridx[u] = nxt; return; } int mxsize = 0; int mi; for(int v: to[u]) { if (v == p) continue; if (sz[v] > mxsize) { mxsize = sz[v]; mi = v; } } assign_idx(mi, h, nxt, u); for(int v: to[u]) { if (v == p || v == mi) continue; assign_idx(v, v, nxt, u); } ridx[u] = nxt; } int lca(int u, int v) { while(head[u] != head[v]) { if (depth[head[u]] > depth[head[v]]) u = parent[head[u]]; else v = parent[head[v]]; } return (depth[u] < depth[v] ? u : v); } // returns (paths upto lca from x (excluding lca), those from y, lca) std::tuple>, std::vector>, int> paths(int x, int y) { std::tuple>, std::vector>, int> ret; std::vector>& x_paths = get<0>(ret); std::vector>& y_paths = get<1>(ret); int& lca = get<2>(ret); while(head[x] != head[y]) { int xhead = head[x], yhead = head[y]; if (depth[xhead] > depth[yhead]) { x_paths.emplace_back(x, xhead); x = parent[xhead]; } else { y_paths.emplace_back(y, yhead); y = parent[yhead]; } } if (depth[x] > depth[y]) { int ychild = inv[idx[y] + 1]; x_paths.emplace_back(x, ychild); x = y; } else if (depth[x] < depth[y]) { int xchild = inv[idx[x] + 1]; y_paths.emplace_back(y, xchild); y = x; } lca = x; return ret; } int dist(int u, int v) { int w = lca(u, v); return depth[u] + depth[v] - 2 * depth[w]; } }; int op(int x, int y) {return x ^ y;} int e() {return 0;} int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; VI c_orig(n); rep(i, n) cin >> c_orig[i]; VVI to(n); rep(_, n - 1) { int a, b; cin >> a >> b; a--, b--; to[a].push_back(b); to[b].push_back(a); } HLD hld(to); VI c(n); rep(i, n) c[hld.idx[i]] = c_orig[i]; segtree seg(c); while(q--) { int t, x, y; cin >> t >> x >> y; x--; if (t == 1) { int idx = hld.idx[x]; seg.set(idx, seg.get(idx) ^ y); } else { int ans = seg.prod(hld.idx[x], hld.ridx[x]); cout << ans << '\n'; } } }