// // main.cpp // No416 // // Created by nanophoto on 2016/09/18. // Copyright © 2016年 nanophoto. All rights reserved. // #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long int #define ti4 tuple #define pii pair #define REP(x,n) for(int x = 0;x < n;x++) template void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } struct UnionFind { vector m[(int)(1e6+1)]; int data[(int)(1e6+1)]; UnionFind(int size) { for(int i = 0;i < size;i++) { data[i] = i; m[i].push_back(i); } } bool unionSet(int x, int y, vector& v, int times) { x = root(x); y = root(y); if (x != y) { int l = min(x, y); int u = max(x, y); for(auto& e : m[u]) { m[l].push_back(e); if(l == 0) { v[e] = times; } } data[u] = l; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { if(data[x] == x) { return x; } data[x] = root(data[x]); return data[x]; } }; const ll mod = (ll)(1e6+7); struct SimpleHash { size_t operator()(const std::pair& p) const { return p.first * mod + p.second; } }; unordered_set ad; unordered_set rem; vector qs; int main() { int n, m, q; cin >> n >> m >> q; REP(x,m) { int a, b; cin >> a >> b; a--; b--; ad.insert(make_pair(a,b)); } REP(x,q) { int a, b; cin >> a >> b; a--; b--; rem.insert(make_pair(a,b)); qs.push_back(make_pair(a,b)); } UnionFind uf(n); vector v(n); fill(v.begin(), v.end(), 0); for(auto& e : ad) { if(rem.find(e) == rem.end()) { uf.unionSet(e.first, e.second, v, -1); } } for(int i = q-1; i >= 0;i--) { uf.unionSet(qs[i].first, qs[i].second, v, i + 1); //for(int k = 0;k < n;k++) //{ // cout << " " << k << " " << uf.root(k) << endl; //} //cout << endl; } for(int i = 1;i < n;i++) { cout << v[i] << endl; } }