#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) struct HLD{ int N; vector P; vector PP; vector PD; vector D; vector rangeL; vector rangeR; HLD(const vector>& E = {}){ N = E.size(); P.assign(N, -1); vector I = {0}; rep(i,I.size()){ int p = I[i]; for(int e : E[p]) if(P[p] != e){ I.push_back(e); P[e] = p; } } vector Z(N, 1); for(int i=N-1; i>=1; i--) Z[P[I[i]]] += Z[I[i]]; PP.resize(N); for(int i=0; i nx(N, -1); for(int p : I) if(p != 0){ if(nx[P[p]] == -1) nx[P[p]] = p; if(Z[nx[P[p]]] < Z[p]) nx[P[p]] = p; } rep(i,N) if(nx[i] != -1) PP[nx[i]] = i; for(int p : I) if(p != 0) PP[p] = PP[PP[p]]; PD.assign(N,N); PD[0] = 0; for(int p : I) if(p != 0) PD[p] = min(PD[PP[p]], PD[P[p]]+1); D.assign(N,0); for(int p : I) D[p] = ((PP[p] == p) ? 0 : D[P[p]]+1); rangeL.assign(N,-1); rangeR.assign(N,-1); vector dfs; int ir = 0; dfs.push_back(0); while(dfs.size()){ int p = dfs.back(); dfs.pop_back(); if(p < 0){ rangeR[-1-p] = ir; continue; } dfs.push_back(-1-p); for(int e : E[p]) if(P[p] != e) if(e != nx[p]) dfs.push_back(e); if(nx[p] != -1) dfs.push_back(nx[p]); rangeL[p] = ir++; } } int lca(int u, int v){ if(PD[u] < PD[v]) swap(u, v); while(PD[u] > PD[v]) u = P[PP[u]]; while(PP[u] != PP[v]){ u = P[PP[u]]; v = P[PP[v]]; } return (D[u] > D[v]) ? v : u; } vector> getpath(int r, int c){ vector> res; while(PD[r] < PD[c]){ res.push_back({ rangeL[PP[c]], rangeL[c]+1 }); c = P[PP[c]]; } if(PP[r] != PP[c]) return {}; if(D[r] > D[c]) return {}; res.push_back({ rangeL[r], rangeL[c]+1 }); reverse(res.begin(), res.end()); return move(res); } }; struct RQ { using S = ll; static S op(S l, S r){ return { l ^ r }; } static S e(){ return { 0 }; } int N; vector A; void mergev(int i){ if(i& a) : RQ(a.size()){ for(int i=0; i=1; i--) mergev(i); } void set(int p, S x){ p+=N; A[p] = x; for(int d=1; (1<>d); } S get(int p){ return A[N+p]; } S prod(int l, int r, int a=0, int b=0, int i=-1){ if(i==-1){ a=0; b=N; i=1; } if(r<=a || b<=l) return e(); if(l<=a && b<=r) return A[i]; S q1 = prod(l, r, a, (a+b)/2, i*2); S q2 = prod(l, r, (a+b)/2, b, i*2+1); return op(q1, q2); } }; int main() { int N,Q; cin >> N >> Q; vector A(N); rep(i,N) cin >> A[i]; vector> E(N); rep(i,N-1){ int u,v; cin >> u >> v; u--; v--; E[u].push_back(v); E[v].push_back(u); } HLD hld(E); RQ rq(N); rep(i,N) rq.set(hld.rangeL[i], A[i]); rep(q,Q){ int t; cin >> t; if(t == 1){ int p,x; cin >> p >> x; p--; int rp = hld.rangeL[p]; rq.set(rp, rq.get(rp) ^ x); } if(t == 2){ int u, x; cin >> u >> x; u--; ll ans = rq.prod(hld.rangeL[u], hld.rangeR[u]); cout << ans << "\n"; } } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;