#include using namespace std; const int N = 1e5; int par[N]; list items[N]; struct node { int val; node *next; }; node body[N]; node *head[N]; node *tail[N]; int size[N]; void join(int x, int y) { tail[x]->next = head[y]; tail[x] = tail[y]; } int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (size[x] < size[y]) swap(x, y); size[x] += size[y]; par[y] = x; join(x, y); } int main() { int n, m, q; cin >> n >> m >> q; for (int i = 0; i < n; i++) { size[i] = 1; par[i] = i; head[i] = &body[i]; tail[i] = &body[i]; body[i].val = i; body[i].next = nullptr; } vector> g; set> removed; for (int i = 0; i < m; i++) { int a, b; scanf("%d %d", &a, &b); a--; b--; g.push_back(minmax(a, b)); } vector c(q), d(q); for (int i = 0; i < q; i++) { scanf("%d %d", &c[i], &d[i]); c[i]--; d[i]--; removed.insert(minmax(c[i], d[i])); } for (auto e : g) if (!removed.count(e)) unite(e.first, e.second); vector ans(n); for (int i = 0; i < n; i++) ans[i] = find(0) == find(i) ? -1 : 0; for (int i = q - 1; i >= 0; i--) { c[i] = find(c[i]); d[i] = find(d[i]); if (c[i] == d[i]) continue; if (d[i] == find(0)) swap(c[i], d[i]); if (c[i] == find(0)) { node *it = head[d[i]]; for (node *it = head[d[i]]; it != nullptr; it = it->next) { ans[it->val] = i + 1; } } unite(c[i], d[i]); } for (int i = 1; i < n; i++) { printf("%d\n", ans[i]); } }