#include #define syosu(x) fixed< P; typedef pair pdd; typedef pair pll; typedef vector vi; typedef vector vvi; typedef vector vd; typedef vector vvd; typedef vector vl; typedef vector vvl; typedef vector vs; typedef vector

vp; typedef vector vvp; typedef vector vpll; typedef pair pip; typedef vector vip; const int inf=1<<30; const ll INF=1ll<<60; const double pi=acos(-1); const double eps=1e-9; const ll mod=1e9+7; const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0}; class Segment_Tree{ private: int n; vi date; int Rec(int a,int b,int k,int l,int r){ if(r<=a||b<=l) return -1; if(a<=l&&r<=b) return date[k]; int m=(l+r)/2; return max(Rec(a,b,k*2+1,l,m),Rec(a,b,k*2+2,m,r)); } public: void Init(int n_){ n=1; while(n0){ k=(k-1)/2; date[k]=max(date[k*2+1],date[k*2+2]); } } int Query(int a,int b){ return Rec(a,b,0,0,n); } int Open(int k){ return date[k+n-1]; } }; class Graph{ private: int n; vvi g; vi vid,head,sub,hvy,par,dep,inv; Segment_Tree st; vi imos,big; //dep; vp edge; void HLdfs(int rt){ stack

sta; sta.push({rt,0}); while(!sta.empty()){ P p=sta.top();sta.pop(); int v=p.first,I=p.second; if(I<(int)g[v].size()){ int u=g[v][I]; sta.push({v,I+1}); if(u==par[v]) continue; par[u]=v; dep[u]=dep[v]+1; sta.push({u,0}); } else{ int M=0; sub[v]++; for(auto u:g[v]) if(u!=par[v]){ sub[v]+=sub[u]; if(M q; q.push(rt); while(!q.empty()){ int v=q.front();q.pop(); for(int u=v;u!=-1;u=hvy[u]){ vid[u]=id++; inv[vid[u]]=u; head[u]=v; for(auto w:g[u]) if(w!=par[u]&&w!=hvy[u]) q.push(w); } } } int Query_vertex(int u,int v){ int M=-1; while(1){ if(vid[u]>vid[v]) swap(u,v); M=max(M,st.Query(max(vid[head[v]],vid[u]),vid[v]+1)); if(head[u]==head[v]) break; v=par[head[v]]; } return M; } void HL(int v){ head=sub=par=dep=inv=vi(n); vid=hvy=par=vi(n,-1); st.Init(n); HLdfs(0);HLbfs(0); } void Bdfs(int v,int d){ dep[v]=d; for(auto u:g[v]) if(dep[u]==-1) Bdfs(u,d+1); } int BDFS(int v){ int d=dep[v],S=0; for(auto u:g[v]){ int D=dep[u]; if(D==d-1) continue; if(D==d+1) S+=BDFS(u); else if(D > q(N); map mp; for(int i=0;i>t>>A>>B; A=big[A-1]; if(t==1){ q[A].push(B); G.st.Update(G.vid[A],q[A].top()); mp[B]=A; } else{ B=big[B-1]; int res=G.Query_vertex(A,B); ans.push_back(res); tmp++; cout<>n>>m>>q; Graph g(n); for(int i=0;i>u>>v; g.add_edge(u-1,v-1); } g.solve(q); }