#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int par[200020]; set> st; pair p[200020], p1[200020]; int ans[200020]; vector> vec(200020); int root(int x) { if (par[x] == x) { return x; } else { return par[x] = root(par[x]); } } int main() { int n, m, q; cin >> n >> m >> q; for (int i = 1; i <= n; i++) { par[i] = i; vec[i].emplace_back(i); } for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; p[i] = { a,b }; st.insert(p[i]); } for (int i = 0; i < q; i++) { int c, d; cin >> c >> d; p1[i] = { c,d }; auto itr = st.lower_bound({ c,d }); st.erase(itr); } for (auto itr = st.begin(); itr != st.end(); itr++) { pair now = *itr; int x = now.first, y = now.second; int x1 = root(x), y1 = root(y); if (x1 != y1) { par[x1] = y1; for (int j = 0; j < vec[x1].size(); j++) { vec[y1].emplace_back(vec[x1][j]); } } } for (int i = 2; i <= n; i++) { if (root(1) == root(i)) { ans[i] = -1; } else { ans[i] = 0; } } reverse(p1, p1 + q); for (int i = 0; i < q; i++) { int x = p1[i].first, y = p1[i].second; int x1 = root(x), y1 = root(y); if (x1 != y1) { if (x1 == root(1)) { for (int j = 0; j < vec[y1].size(); j++) { if (ans[vec[y1][j]] == 0) { ans[vec[y1][j]] = q - i; } } } if (y1 == root(1)) { for (int j = 0; j < vec[x1].size(); j++) { if (ans[vec[x1][j]] == 0) { ans[vec[x1][j]] = q - i; } } } par[x1] = y1; for (int j = 0; j < vec[x1].size(); j++) { vec[y1].emplace_back(vec[x1][j]); } } } for (int i = 2; i <= n; i++) { cout << ans[i] << endl; } }