#include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template using V = vector; template using VV = V>; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); } #define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,N) for(int i=0;i<(int)(N);i++) #define rep1(i,N) for(int i=1;i<=(int)(N);i++) #define fs first #define sc second #define eb emplace_back #define pb eb #define all(x) x.begin(),x.end() template void chmin(T& t, const U& u) { if (t > u) t = u; } template void chmax(T& t, const U& u) { if (t < u) t = u; } // bit op int popcnt(uint x) { return __builtin_popcount(x); } int popcnt(ull x) { return __builtin_popcountll(x); } int bsr(uint x) { return 31 - __builtin_clz(x); } int bsr(ull x) { return 63 - __builtin_clzll(x); } int bsf(uint x) { return __builtin_ctz(x); } int bsf(ull x) { return __builtin_ctzll(x); } template struct Segtree { int _n, size, log; vector d; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } Segtree() : Segtree(0) { } Segtree(int n) : Segtree(vector(n, e())) { } Segtree(const vector& v) : _n(int(v.size())) { size = bit_ceil((unsigned)_n); log = countr_zero((unsigned)size); d = vector(2 * size, e()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { p += size; d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } S get(int p) { return d[p + size]; } S prod(int l, int r) { S sml = e(), smr = e(); l += size; r += size; while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { return d[1]; } template int max_right(int l) { return max_right(l, [](S x) { return f(x); }); } template int max_right(int l, F f) { if (l == _n) return _n; l += size; S sm = e(); do { while (l % 2 == 0) l >>= 1; if (!f(op(sm, d[l]))) { while (l < size) { l = (2 * l); if (f(op(sm, d[l]))) { sm = op(sm, d[l]); l++; } } return l - size; } sm = op(sm, d[l]); l++; } while ((l & -l) != l); return _n; } template int min_left(int r) { return min_left(r, [](S x) { return f(x); }); } template int min_left(int r, F f) { if (r == 0) return 0; r += size; S sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!f(op(d[r], sm))) { while (r < size) { r = (2 * r + 1); if (f(op(d[r], sm))) { sm = op(d[r], sm); r--; } } return r + 1 - size; } sm = op(d[r], sm); } while ((r & -r) != r); return 0; } }; //頂点vに関する情報はgrp[v]番目のセグ木のpos[v]番目に入れる //g番目のセグ木の長さはgsz[g] struct HL_Decomp{ int N,gord; vector> tr; vector par,dep,sub,grp,pos,gsz,gpar,gdep; HL_Decomp(int N,vector> graph):gord(),par(N),dep(N),sub(N),grp(N),pos(N),gsz(N),gpar(N),gdep(N){ tr=graph; dfs1(0,-1,0); dfs2(0,-1,gord++,0); } int dfs1(int v,int p,int d){ par[v]=p; sub[v]=1; dep[v]=d; for(auto to:tr[v])if(to!=p)sub[v]+=dfs1(to,v,d+1); return sub[v]; } void dfs2(int v,int p,int g,int d){ grp[v]=g; if(gsz[g]==0){ gpar[g]=p; gdep[g]=d; } pos[v]=gsz[g]++; pair si(0,-1); for(auto to:tr[v])if(to!=p)chmax(si,pair(sub[to],to)); for(auto to:tr[v])if(to!=p){ if(to==si.second)dfs2(to,v,g,d); else dfs2(to,v,gord++,d+1); } } int LCA(int a,int b){ if(gdep[grp[a]]>gdep[grp[b]])swap(a,b); while(gdep[grp[a]]dep[b])swap(a,b); return a; } //{g,l,r}はg番目のセグ木のl~rという意味 //lrなら[r:l)の逆順 //edge=trueの場合はlcaを含まない区間を返す vector> query(int a,int b,bool edge=false){ vector> l,r; while(gdep[grp[a]]>gdep[grp[b]]){ l.emplace_back(grp[a],pos[a]+1,0); a=gpar[grp[a]]; } while(gdep[grp[a]]dep[b])l.emplace_back(grp[a],pos[a]+1,pos[b]+e); else if(dep[a]>N>>Q; vector C(N); for(int i=0;i>C[i]; } vector> graph(N); for(int i=0;i>a>>b; a-=1;b-=1; graph[a].push_back(b); graph[b].push_back(a); } HL_Decomp HL(N,graph); vector> ST(N); for(int g=0;g(HL.gsz[g]+1); } for(int x=0;x>T>>x>>y; x-=1; if(T==1){ for(auto [g,l,r]:HL.query(x,0)){ ST[g].set(l,ST[g].get(l)^y); ST[g].set(r,ST[g].get(r)^y); } } else{ int ans=ST[HL.grp[x]].prod(0,HL.pos[x]+1); cout<