#include #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)n;++i) #define each(a, b) for(auto (a): (b)) #define all(v) (v).begin(),(v).end() #define fi first #define se second #define pb push_back #define show(x) cout <<#x<<" = "<<(x)<P; const int MAX_N = 100005; vector G[MAX_N]; set hoge[MAX_N]; vector

rem; vector kind; vector > inc; void initial(int n) { kind.resize(n); inc.resize(n); rep(i,n){ kind[i] = i; inc[i].assign(1,i); } } void unite(int a,int b) { if(inc[kind[a]].size() < inc[kind[b]].size()){ swap(a,b); } int ga = kind[a],gb = kind[b]; rep(i,inc[gb].size()){ kind[inc[gb][i]] = ga; } inc[ga].insert(inc[ga].end(),inc[gb].begin(),inc[gb].end()); inc[gb].clear(); } bool same(int a,int b){ return kind[a] == kind[b]; } int main() { int n,m,q; cin >> n >> m >> q; rep(i,m){ int a,b; scanf("%d%d",&a,&b); hoge[a-1].insert(b-1); hoge[b-1].insert(a-1); } rep(i,q){ int c,d; scanf("%d%d",&c,&d); rem.pb(P(c-1,d-1)); hoge[c-1].erase(d-1); hoge[d-1].erase(c-1); } rep(i,n){ each(it,hoge[i]){ G[i].pb(it); } } initial(n); rep(i,n){ rep(j,G[i].size()){ if(!same(i,G[i][j])){ unite(i,G[i][j]); } } } vector ans(n-1,0); rep(i,n-1){ if(same(0,i+1)){ ans[i] = -1; } } for(int i=q-1;i>=0;i--){ P p = rem[i]; if(!same(p.fi,p.se)){ if(same(0,p.fi)){ rep(j,inc[kind[p.se]].size()){ ans[inc[kind[p.se]][j]-1] = i+1; } unite(0,p.se); }else if(same(0,p.se)){ rep(j,inc[kind[p.fi]].size()){ ans[inc[kind[p.fi]][j]-1] = i+1; } unite(0,p.fi); }else{ unite(p.fi,p.se); } } } rep(i,n-1){ printf("%d\n",ans[i]); } return 0; }