#include #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define FORR(i,a,b) for (int i=(a);i>=(b);i--) #define pb push_back #define pcnt __builtin_popcount #define show(x) cout<<#x<<" = "< pii; typedef vector vi; typedef vector vvi; typedef vector vpii; typedef set si; typedef pair pll; typedef vector vl; typedef vector vvl; typedef vector vpll; typedef set sl; templatestring join(vector&v) {stringstream s;FOR(i,0,sz(v))s<<' '<b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;} int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;} void dout(double d){printf("%.12f\n",d);} const int iinf = 1e9; const ll linf = 1e18; const int mod = 1e9+7; const double pi = acos(-1); const double eps = 1e-10; struct UnionFind{ int ans[100001]; vi p; vpii li; // next, tail void init(int n){ p.resize(n); li.resize(n); FOR(i, 0, n) p[i] = -1; FOR(i, 0, n) li[i] = pii(-1, i); } int find(int a){ if(p[a] < 0) return a; p[a] = find(p[a]); return p[a]; } void merge(int a, int b, bool z, int q){ a = find(a); b = find(b); if(a == b) return; if(a > b) swap(a, b); p[b] = a; li[li[a].se].fi = b; li[a].se = li[b].se; if(a == 1 && z){ int id = b; while(id > 0){ ans[id] = q; id = li[id].fi; } } } }; int ans[100001]; int n, m, q; UnionFind uf; map e; pii Q[200000]; main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m >> q; uf.init(n + 1); FOR(i, 0, m){ int a, b; cin >> a >> b; e[pii(a, b)] = true; } FOR(i, 0, q){ int c, d; cin >> c >> d; Q[i] = pii(c, d); e[Q[i]] = false; } each(itr, e){ if(!itr->se)continue; uf.merge(itr->fi.fi, itr->fi.se, false, 0); } FOR(i, 1, 100002)ans[i] = -1; FORR(i, q-1, 0) uf.merge(Q[i].fi, Q[i].se, true, i+1); FOR(i, 2, n+1) cout << (uf.ans[i] == 0 ? -1 : uf.ans[i] )<< "\n"; }