#include #define FL(i,a,b) for(int i=(a);i<=(b);i++) #define FR(i,a,b) for(int i=(a);i>=(b);i--) #define ll long long #define PII pair using namespace std; const int MAXN = 1e5 + 10; int dep[MAXN<<1],f[30][MAXN<<1],fa[MAXN<<1],val[MAXN<<1]; PII a[MAXN<<1],e[MAXN<<1]; mapmp; vectorG[MAXN]; int find(int x){ if(fa[x]==x) return x; return fa[x]=find(fa[x]); } int lca(int x,int y){ if(dep[x]=dep[y]) x=f[i][x]; if(x==y) return x; FR(i,29,0) if(f[i][x]!=f[i][y]) x=f[i][x],y=f[i][y]; return f[0][x]; } void dfs(int u,int fth){ dep[u]=dep[fth]+1; f[0][u]=fth; FL(i,1,29) f[i][u]=f[i-1][f[i-1][u]]; for(int v:G[u]){ if(v==fth) continue; // printf("%d->%d\n",u,v); dfs(v,u); } } bool cmp(PII p,PII q){ return mp[{p.first,p.second}]>mp[{q.first,q.second}]; } int main(){ int n,m,q,cnt; scanf("%d%d%d",&n,&m,&q); FL(i,1,n) fa[i]=i; FL(i,1,m) scanf("%d%d",&e[i].first,&e[i].second),mp[{e[i].first,e[i].second}]=mp[{e[i].second,e[i].first}]=q+1; FL(i,1,q){ scanf("%d%d",&a[i].first,&a[i].second); mp[{a[i].first,a[i].second}]=mp[{a[i].second,a[i].first}]=i; // del[{a[i].first,a[i].second}]=del[{a[i].second,a[i].first}]=1; } sort(e+1,e+m+1,cmp); cnt=n; FL(i,1,m){ int u=find(e[i].first),v=find(e[i].second); if(u==v) continue; // printf("(%d,%d) %d %d\n",e[i].first,e[i].second,u,v); cnt++; fa[u]=fa[v]=fa[cnt]=cnt; val[cnt]=mp[{e[i].first,e[i].second}]; G[cnt].push_back(u); G[cnt].push_back(v); } // FL(i,1,n) printf("find(%d)=%d\n",i,find(i)); dfs(cnt,0); FL(i,2,n){ if(find(i)!=find(1)){ puts("0"); continue; } // puts("work"); int t=lca(i,1); // printf("t=%d\n",t); printf("%d\n",(val[t]==q+1?-1:val[t])); } }