#include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long int; #define chmax(x,y) (x) = ((x) > (y)) ? (x) : ((x) = (y)); #define chmin(x,y) (x) = ((x) < (y)) ? (x) : ((x) = (y)); struct UnionFind { vector parent,rank; UnionFind(int n) { parent = rank = vector (n); for(int i=0;i answer (101010,0); vector X(202020),Y(202020); vector conec[202020]; int main(int argc, char const *argv[]) { int N,M,Q; cin >> N >> M >> Q; set> st; for(int i=0;i> x >> y; st.insert({--x, --y}); } for(int i=0;i> X[i] >> Y[i]; st.erase({--X[i],--Y[i]}); } UnionFind uf(N+1); for(auto &e : st) { uf.connect(e.first,e.second); } for(int i=0;i=0;--i) { if(uf.root(X[i]) != uf.root(Y[i])) { int x = uf.root(X[i]); int y = uf.root(Y[i]); if(x == uf.root(0)) { for(auto &z : conec[y]) { answer[z] = i+1; } } if(y == uf.root(0)) { for(auto &z : conec[x]) { answer[z] = i+1; } } if(uf.rank[x] < uf.rank[y])swap(x,y); uf.connect(x,y); for(auto &z : conec[y])conec[x].push_back(z); conec[y].clear(); if(uf.root(x)==y) swap(conec[x],conec[y]); } } for(int i=1;i