#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair(a,b) #define pb(a) push_back(a) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="< par, rank, sizes; // parent, depth, size(only for root) UnionFind(int sz) : par(sz), rank(sz, 0), sizes(sz, 1){ rep(i,sz) par[i]=i; // initial tree is independent each other } int find(int x){ if(par[x]==x) return x; else return par[x] = find(par[x]); } void unite(int x, int y){ x=find(x); y=find(y); if(x==y) return; // already belong to same tree if(rank[x] < rank[y]){ // y becomes parent node par[x] = y; sizes[y] += sizes[x]; } else { // x becomes parent node par[y]=x; if(rank[x]==rank[y]) rank[x]++; sizes[x] += sizes[y]; } } bool same(int x, int y){ return find(x) == find(y); } int size(int x){ return sizes[find(x)]; } }; // END class UnionFind typedef pair P; int main(){ int n,m,q; cin>>n>>m>>q; set

brg; rep(i,m){ int a,b; scanf("%d %d", &a, &b); a--;b--; brg.insert(mp(a,b)); } vector a(q), b(q); rep(i,q){ scanf("%d %d", &a[i], &b[i]); a[i]--;b[i]--; brg.erase(mp(a[i],b[i])); } vector res(n); vector l(n,0), r(n,q+1); rep(reps, 18){ UnionFind uf(n); for(P p : brg){ uf.unite(p.fi, p.se); } vector > s(m+1); rep(i,n-1) s[(l[i]+r[i])/2].pb(i); rep(i,q+1){ if(i!=0) uf.unite(a[q-i], b[q-i]); for(int j : s[i]){ if(uf.same(0,j+1)) r[j]=i; else l[j]=i; } } } rep(i,n-1){ if(r[i] == 0) r[i]=q+2;} rep(i,n-1) printf("%d\n", q-r[i]+1); return 0; }