#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef vector vi; typedef vector vvi; #define rep(i,n) for(ll i=0;i<(n);i++) #define tii tuple #define tiii tuple #define mt make_tuple #define pb push_back #define ALL(a) (a).begin(),(a).end() #define FST first #define SEC second const int INF = (INT_MAX/2); const ll LLINF = (LLONG_MAX/2); const double eps = 1e-5; const double PI = M_PI; #define DEB cerr<<"!"<0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;} int ans[100001] = {}; set G[100001] = {}; #define Nodes 1000000 class UF{ public: int value[Nodes]; int over[Nodes]; // When over < 0, 'over' keep number of node(using negative number). -1 means this tree is a node. int root(int index){ int t = index; //stack stack_i; while(over[t] >= 0){ //stack_i.push(t); t = over[t]; } /*while(!stack_i.empty()){ int i = stack_i.top(); stack_i.pop(); over[i] = t; }// reconnect */ if(over[t] > 0) over[index] = t; return t; } void merge(int a,int b){ if(this->root(a) == this->root(b)) return; over[root(a)] += over[root(b)]; // over have a number of nodes. over[root(b)] = root(a); } UF(){rep(i,Nodes) over[i] = -1;} // all nodes are root. }; int n,m,q; vector v; UF u; bool used[100001]; void dfs(int pos1,int pos2, int times){ if(u.root(pos2) == u.root(1)) swap(pos1,pos2); //SHOW(q-times,q); stack si; si.push(pos2); while(!si.empty()){ pos2 = si.top(); si.pop(); ans[pos2] = q-times+1; used[pos2] = 0; for(auto itr:G[pos2]) if(used[itr]) si.push(itr); } } int main(){ cin >> n >> m >> q; set input; rep(i,m){ int a,b; cin >> a >> b; input.insert(tii{a,b}); } stack que; rep(i,q){ int c,d; cin >> c >> d; input.erase(tii{c,d}); que.push(tii{c,d}); } for(auto itr:input){ int a,b; tie(a,b) = itr; u.merge(a,b); G[a].insert(b); G[b].insert(a); } for(int i = 2; i <= n; i++) if(u.root(1) == u.root(i)) ans[i] = -1; int i = 1; while(!que.empty()){ int c,d; tie(c,d) = que.top(); que.pop(); if((u.root(1) == u.root(c) || u.root(1) == u.root(d))&&u.root(c) != u.root(d)){ fill_n(used,100001,1); dfs(c,d,i); }else{ G[c].insert(d); G[d].insert(c); } u.merge(c,d); i++; } rep(i,n-1) cout << ans[i+2] << endl; }