#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() int main() { cin.tie(nullptr); int N, M, Q; cin >> N >> M >> Q; vector> B(M), query(Q); set> s; rep(i, 0, M) { cin >> B[i].first >> B[i].second; B[i].first--, B[i].second--; } rep(i, 0, Q) { cin >> query[i].first >> query[i].second; query[i].first--, query[i].second--; s.insert(query[i]); } vector G(N, vector()); rep(i, 0, M) { if (!s.count(B[i])) { G[B[i].first].push_back(B[i].second); G[B[i].second].push_back(B[i].first); } } reverse(all(query)); vector ans(N, 0); vector seen(N, false); queue que; seen[0] = true; que.push(0); while (!que.empty()) { int v = que.front(); que.pop(); for (int next : G[v]) { if (seen[next]) continue; seen[next] = true; ans[next] = -1; que.push(next); } } rep(q, 0, Q) { G[query[q].first].push_back(query[q].second); G[query[q].second].push_back(query[q].first); if (!(seen[query[q].first] ^ seen[query[q].second])) continue; if (seen[query[q].first]) que.push(query[q].first); else que.push(query[q].second); while (!que.empty()) { int v = que.front(); que.pop(); for (int next : G[v]) { if (seen[next]) continue; seen[next] = true; ans[next] = Q - q; que.push(next); } } } rep(i, 1, N) cout << ans[i] << '\n'; }