#include using namespace std; struct edge { int u, v; }; struct node { int val; node *next; }; const int N = 1e5; const int M = 2e5; int n, m, q, par[N], c[M], d[M], ans[M]; bool dead[M]; edge g[M]; node body[N], *head[N], *tail[N]; bool operator<(const edge &a, const edge &b) { return a.u != b.u ? a.u < b.u : a.v < b.v; } int find(int x) { return par[x] = (par[x] == x ? x : find(par[x])); } void unite(int x, int y, int t) { x = find(x); y = find(y); if (x == y) return; if (x > y) swap(x, y); par[y] = x; if (x == 0) { for (node *it = head[y]; it; it = it->next) ans[it->val] = t; } else { tail[x]->next = head[y]; tail[x] = tail[y]; } } int in() { int t; scanf("%d", &t); return t; } int main() { cin >> n >> m >> q; for (int i = 0; i < n; i++) { par[i] = body[i].val = i; head[i] = tail[i] = &body[i]; } for (int i = 0; i < m; i++) g[i].u = in() - 1, g[i].v = in() - 1; sort(g, g + m); for (int i = 0; i < q; i++) { c[i] = in() - 1; d[i] = in() - 1; int k = lower_bound(g, g + m, (edge){ c[i], d[i] }) - g; if (k < m && g[k].u == c[i] && g[k].v == d[i]) dead[k] = true; } for (int i = 0; i < m; i++) if (!dead[i]) unite(g[i].u, g[i].v, -1); for (int i = q - 1; i >= 0; i--) unite(c[i], d[i], i + 1); for (int i = 1; i < n; i++) printf("%d\n", ans[i]); }