#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; struct QuickFind { vector i2g; vector> g2i; QuickFind (int n) { i2g.assign(n,-1); g2i.assign(n, vector()); for (int i = 0; i < n; i++) { i2g[i] = i; g2i[i].emplace_back(i); } } bool same(int ia, int ib) {return i2g[ia] == i2g[ib];} void merge(int ia, int ib) { if (same(ia, ib)) return ; if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) { swap(ia, ib); } int ga = i2g[ia], gb = i2g[ib]; for (auto u : g2i[gb]) { i2g[u] = ga; } g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end()); g2i[gb].clear(); } }; int main(){ int n, m, q; cin >> n >> m >> q; QuickFind qf(n); set

st; rep(i,m) { int a, b; cin >> a >> b; a--; b--; st.insert(make_pair(a, b)); } vector

query(q); rep(i,q) { int c, d; cin >> c >> d; c--; d--; query[i] = make_pair(c, d); st.erase(make_pair(c, d)); } reverse(query.begin(), query.end()); for (auto e : st) qf.merge(e.second, e.first); vector res(n, 0); for (auto e : qf.g2i[qf.i2g[0]]) res[e] = -1; for (int i = 0; i < q; i++) { int u = query[i].first, v = query[i].second; if (!qf.same(u, v)) { if (!qf.same(0,u) && !qf.same(0,v)) { qf.merge(u, v); continue; } if (qf.same(0, u)) { for (auto e : qf.g2i[qf.i2g[v]]) { if (res[e] == 0) res[e] = q - i; } } else { for (auto e : qf.g2i[qf.i2g[u]]) { if (res[e] == 0) res[e] = q - i; } } } qf.merge(u, v); } for (int i = 1; i < n; i++) cout << res[i] << endl; return 0; }