#include using namespace std; int fa[100005]; int findfather(int x){ return x==fa[x]?x:fa[x]=findfather(fa[x]); } int a[200005],b[200005],c[200005],d[200005]; vector>dy[200005]; vector>g[100005]; int ans[100005]; void dfs(int x,int la){ for(auto pi:g[x]){ int cu=pi.first,c2=pi.second; if(cu==la)continue; ans[cu]=min(ans[x],c2); dfs(cu,x); } } int main(){ int n,m,q; scanf("%d%d%d",&n,&m,&q); for(int i=1;i<=n;++i)fa[i]=i; map,int>mp; for(int i=1;i<=m;++i){ scanf("%d%d",&a[i],&b[i]); } for(int i=1;i<=q;++i){ scanf("%d%d",&c[i],&d[i]); dy[i].emplace_back(c[i],d[i]); mp[make_pair(c[i],d[i])]=1; } for(int i=1;i<=m;++i)if(!mp[make_pair(a[i],b[i])]){ dy[q+1].emplace_back(a[i],b[i]); } for(int i=q+1;i>=1;--i)for(auto pi:dy[i]){ int fu=findfather(pi.first),fv=findfather(pi.second); if(fu!=fv){ fa[fu]=fv; g[pi.first].emplace_back(pi.second,i); g[pi.second].emplace_back(pi.first,i); } } ans[1]=q+1; dfs(1,0); for(int i=2;i<=n;++i)printf("%d\n",ans[i]>q?-1:ans[i]); return 0; }