#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} //end struct LowLink{ const int n; vector> g; vector used,ord,low,cmp; LowLink(const int& _n):n(_n),g(n), used(n,0),ord(n,0),low(n,0),cmp(n,-1){ } void add_edge(int u,int v){ g[u].emplace_back(v); g[v].emplace_back(u); } void dfs(int v,int p,int& k){ used[v]=1; low[v]=ord[v]=k++; int cnt=0,sub=0; for(auto& to:g[v]){ if(to==p and (++sub)<=1)continue; if(!used[to]){ cnt++; dfs(to,v,k); chmin(low[v],low[to]); } else chmin(low[v],ord[to]); } } void dfs2(int v,int p,int& k){ if(p!=-1 and ord[p]>=low[v])cmp[v]=cmp[p]; else cmp[v]=k++; for(auto& to:g[v])if(cmp[to]==-1)dfs2(to,v,k); } int run(){ int k=0; rep(i,0,n)if(!used[i])dfs(i,-1,k); k=0; rep(i,0,n)if(cmp[i]==-1)dfs2(i,-1,k); return k; } }; struct HLD{ using P=pair; vector> g; vector sz,in,out,hs,par; void dfs(int v,int p){ par[v]=p; sz[v]=1; if(!g[v].empty() and g[v][0]==p)swap(g[v][0],g[v].back()); for(auto& to:g[v])if(to!=p){ dfs(to,v); sz[v]+=sz[to]; if(sz[g[v][0]]in[v])swap(u,v); if(hs[u]==hs[v])return u; } } vector

get(int u,int v,bool es=0){ vector

res; for(;;v=par[hs[v]]){ if(in[u]>in[v])swap(u,v); if(hs[u]==hs[v])break; res.emplace_back(in[hs[v]],in[v]+1); } res.emplace_back(in[u]+es,in[v]+1); return res; } }; templatestruct SegmentTree{ int sz; vector data; const M m1; SegmentTree(int n,const M &m1):m1(m1){ sz=1; while(sz v){ rep(i,0,v.size())data[i+sz]=v[i]; for(int k=sz-1;k>0;k--)data[k]=f(data[2*k],data[2*k+1]); } void update(int k,const N &x){ k+=sz; data[k]=g(data[k],x); while(k>>=1)data[k]=f(data[2*k],data[2*k+1]); } M query(int a,int b){ M L=m1,R=m1; for(a+=sz,b+=sz;a>=1,b>>=1){ if(a&1)L=f(L,data[a++]); if(b&1)R=f(data[--b],R); } return f(L,R); } M operator[](const int &k)const{return data[k+sz];} }; typedef pair P; P f(P a,P b){return max(a,b);} P g(P a,P b){return b;} int main(){ int n,m,q; cin>>n>>m>>q; LowLink low(n); vector

es; rep(i,0,m){ int x,y; cin>>x>>y; x--; y--; es.push_back({x,y}); low.add_edge(x,y); } int d=low.run(); HLD hld(d); for(auto& p:es){ int u=low.cmp[p.first]; int v=low.cmp[p.second]; if(u!=v){ hld.add_edge(u,v); } } hld.run(); SegmentTree seg(n,{-1,inf}); vector> qs(d); while(q--){ int t; cin>>t; if(t==1){ int u,w; cin>>u>>w; u--; u=low.cmp[u]; qs[u].insert(w); seg.update(hld.in[u],{*qs[u].rbegin(),u}); } else{ int u,v; cin>>u>>v; u--; v--; u=low.cmp[u],v=low.cmp[v]; if(u>v)swap(u,v); auto ps=hld.get(u,v); P mx={-1,-1}; for(auto& p:ps){ chmax(mx,seg.query(p.first,p.second)); } if(mx.first==-1)puts("-1"); else{ int id=mx.second; qs[id].erase(mx.first); if(qs[id].empty())seg.update(hld.in[id],{-1,id}); else seg.update(hld.in[id],{*qs[id].rbegin(),id}); cout<