//Writer解 その2 #include #include #include #include using namespace std; using namespace atcoder; void calculate_depth(const vector>& G,vector& depth){ int n=G.size(); deque dq; vector check(n,false); dq.push_back(0); while(!dq.empty()){ int q=dq.back(); dq.pop_back(); check.at(q)=true; for(int i:G.at(q)){ if(check.at(i))continue; dq.push_back(i); depth.at(i)=depth.at(q)+1; } } return; } void separate(const vector>& G,const vector& depth,vector>& parents,vector>& children){ int n=G.size(); for(int i=0;i>& parents,vector>& children,vector& C,vector>& Nodes,vector& A){ int n=parents.size(),next,now=0,cnt=0; vector check(n,false); while(true){ if(!check.at(now)){ Nodes.at(now).push_back((int)A.size()); A.push_back(C.at(now)); cnt++; check.at(now)=true; } if(!children.at(now).empty()){ next=children.at(now).back(); children.at(now).pop_back(); }else if(!parents.at(now).empty()){ Nodes.at(now).push_back(cnt); next=parents.at(now).back(); }else{ Nodes.at(now).push_back(cnt); break; } now=next; } return; } int op(const int a,const int b){ return a^b; } int e(){ return 0; } int main(){ int N,Q; cin>>N>>Q; vectorC(N); vector>G(N); for(int i=0;i>C.at(i); for(int i=0;i>a>>b; G.at(a-1).push_back(b-1); G.at(b-1).push_back(a-1); } vectordepth(N,0); calculate_depth(G,depth); vector>parents(N); vector>children(N); separate(G,depth,parents,children); vector>Nodes(N); vectorA; convert(parents,children,C,Nodes,A); segtree seg(A); int T,x,y,r,l,R,L,P; for(int i=0;i>T>>x>>y; x--; if(T==1){ l=Nodes.at(x).at(0); L=seg.get(l); seg.set(l,L^y); }else{ l=Nodes.at(x).at(0); r=Nodes.at(x).at(1); P=seg.prod(l,r); cout<