#include #define endl '\n' #define sz(x) (signed)(x).size() using namespace std; void file_IO(){ freopen("evacuate.in", "r", stdin); freopen("evacuate.out", "w", stdout); } const int N = 1e5 + 10; const int M = 2e5 + 10; int n, m, q, fa[N], a[M], b[M], c[M], d[M]; int ans[N]; map g[N]; vector vec[N]; int Find(int x){ return (fa[x] == x ? x : (fa[x] = Find(fa[x]))); } void work(int x, int v){ for (auto u : vec[x]) ans[u] = v; } void merge(int x, int y, int v){ if (Find(1) == x) work(y, v); else if (Find(1) == y) work(x, v); if (sz(vec[x]) < sz(vec[y])) swap(x, y); fa[y] = x; for (auto u : vec[y]) vec[x].push_back(u); vec[y].clear(); } signed main(){ //file_IO(); ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> m >> q; for (int i = 1; i <= m; i++) cin >> a[i] >> b[i]; for (int i = 1; i <= q; i++){ cin >> c[i] >> d[i]; g[c[i]][d[i]] = g[d[i]][c[i]] = 1; } memset(ans, 0, sizeof(ans)); for (int i = 1; i <= n; i++){ fa[i] = i; vec[i].push_back(i); } for (int i = 1, u, v; i <= m; i++){ if (g[a[i]][b[i]]) continue; u = Find(a[i]), v = Find(b[i]); if (u ^ v) merge(u, v, -1); } for (int i = q, u, v; i; i--){ u = Find(c[i]), v = Find(d[i]); if (u ^ v) merge(u, v, i); } for (int i = 2; i <= n; i++) cout << ans[i] << endl; return 0; }