#include #include #include #include using namespace std; static const int MAX = 200000; static const int NIL = -1; int n; vector G[MAX]; int color[MAX/2]; void dfs(int r, int c) { stack S; S.push(r); color[r] = c; while (!S.empty()) { int u = S.top(); S.pop(); for (int i = 0; i < G[u].size(); i++) { int v = G[u][i]; if (color[v] == c-1) { color[v] = c; S.push(v); } } } } void assignColor() { for (int i = 1; i <= n; i++) color[i] = NIL; dfs(1, 1); } int main() { int n, m, q; cin >> n >> m >> q; int a, b; for (int i = 0; i < m; i++) { cin >> a >> b; G[a].push_back(b); G[b].push_back(a); } assignColor(); int c, d; for (int i = 0; i < q; i++) { cin >> c >> d; G[c].erase(find(G[c].begin(), G[c].end(), d)); G[d].erase(find(G[d].begin(), G[d].end(), c)); dfs(1, i + 2); } for (int i = 2; i <= n; i++) { if (color[i] == q+1)cout << -1 << endl; else cout << color[i] << endl; } return 0; }