#include using namespace std; struct Kruskal_dsu { public: Kruskal_dsu() : _n(0) {} Kruskal_dsu(int n) : _n(n), parent_or_size(n, -1), dat(n) {} bool merge(int u, int v, int w) { assert(0 <= u && u < _n); assert(0 <= v && v < _n); int x = leader(u), y = leader(v); if (x == y) return false; if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y); parent_or_size[x] += parent_or_size[y]; parent_or_size[y] = x; dat[y] = w; return true; } bool same(int v, int u) { assert(0 <= v && v < _n); assert(0 <= u && u < _n); return leader(v) == leader(u); } int leader(int v) { assert(0 <= v && v < _n); return parent_or_size[v] < 0 ? v : leader(parent_or_size[v]); } int size(int v) { assert(0 <= v && v < _n); return -parent_or_size[leader(v)]; } int max_edge(int u, int v){ int ans = 1 << 30; while(u != v){ if (dat[u] < dat[v]) std::swap(u, v); ans = dat[u], u = parent_or_size[u]; if(u < 0)return -1; } return ans; } private: int _n; // root node: -1 * component size // otherwise: parent std::vector parent_or_size, dat; }; int main(){ ios::sync_with_stdio(false); cin.tie(0); int N, M, Q, u, v; cin >> N >> M >> Q; vector> edge(M), edge2(Q); vector used(M); for(int i = 0; i < M; i++){ cin >> u >> v; --u, --v; if(u > v)swap(u, v); edge[i] = {u, v}; } sort(edge.begin(), edge.end()); for(int i = 0; i < Q; i++){ cin >> u >> v; u--, v--; if(u > v)swap(u, v); int j = lower_bound(edge.begin(), edge.end(), make_pair(u, v)) - edge.begin(); used[j] = true; edge2[i] = {u, v}; } Kruskal_dsu uf(N); for(int i = 0; i < M; i++){ if(used[i])continue; tie(u, v) = edge[i]; uf.merge(u, v, Q); } for(int i = Q - 1; i >= 0; i--){ tie(u, v) = edge2[i]; uf.merge(u, v, i); } for(int i = 1; i < N; i++){ int v = uf.max_edge(0, i); if(v == -1)cout << 0 << '\n'; else if(v >= Q)cout << -1 << '\n'; else cout << ++v << '\n'; } }