#include #define ALL(v) std::begin(v),std::end(v) using lint=long long; using ld=long double; templateusing numr=std::numeric_limits; void cmn(lint&x,lint y){if(x>y)x=y;} void cmx(lint&x,lint y){if(xstruct segtree{ // {{{ // member variables lint n,N; BinaryOp op; Value id; std::vectortable; // constructors segtree()=default; segtree(lint n_, BinaryOp const& op_, Value id_): n(n_), N(1ll<<(std::numeric_limits::digits-__builtin_clzll(n)+1)), op(op_), id(id_), table(2*N,id){} // other member functions void update(lint i){table.at(i)=op(table.at(2*i),table.at(2*i+1));} void set(lint i, Value const& x){i+=N;table.at(i)=x;for(i>>=1;i;i>>=1)update(i);} void lazy_set(lint i, Value const& x){table.at(i+N)=x;} void build(){for(lint i=N-1;i;i--)update(i);} Value get(lint i)const{return table.at(i+N);} Value query(lint l, lint r)const{ Value ans=id; std::vectorright; for(l+=N,r+=N;l>=1,r>>=1){ if(l&1)ans=op(ans,table.at(l++)); if(r&1)right.push_back(--r); } std::reverse(ALL(right)); for(lint x:right)ans=op(ans,table.at(x)); return ans; } std::vectorto_vec()const{ std::vectorans(n); for(lint i=0;i>n>>k>>q; std::vectorc(n),a(k); for(lint&x:c)std::cin>>x; for(lint&x:a){std::cin>>x;x--;} std::vector>g(n); for(lint i=0;i>u>>v;u--,v--; g.at(v).push_back(u); } lint N=4*n-2; auto eular=segtree(N,min_fn,std::pair(n,0)); std::vector>pos(n); lint eular_sz=0; auto dfs=[&](auto&&f,lint x,lint d)->void{ pos.at(x).first=eular_sz; eular.set(eular_sz++,std::pair(d,x)); for(lint y:g.at(x)){ eular.set(eular_sz++,std::pair(d,x)); cmx(c.at(y),c.at(x)); f(f,y,d+1); eular.set(eular_sz++,std::pair(d,x)); } pos.at(x).second=eular_sz; eular.set(eular_sz++,std::pair(d,x)); }; dfs(dfs,0,0); auto lca=segtree(n,[&](lint x,lint y){return x==-1?y:y==-1?x:eular.query(pos.at(x).first,pos.at(y).second).second;},-1); for(lint i=0;i>com; if(com==1){ lint x,y;std::cin>>x>>y;x--,y--; lca.set(x,y); } if(com==2){ lint l,r;std::cin>>l>>r;l--; std::cout<