#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} const int MAX_N = 200100; int par[MAX_N]; // 親 int rank_[MAX_N]; // 木の深さ int cnt_[MAX_N]; // 属する頂点の個数(親のみ正しい) // n要素で初期化 void UFinit(){ for(int i=0;i> n >> m >> q; int a[m], b[m], c[q], d[q]; rep(i,m){ cin >> a[i] >> b[i]; a[i]--; b[i]--; } rep(i,q){ cin >> c[i] >> d[i]; c[i]--; d[i]--; } map mp; rep(i,m)mp[P(a[i],b[i])] = q + 1; rep(i,q)mp[P(c[i],d[i])] = i + 1; vector

G[q+2]; for(auto x : mp) G[x.second].push_back(x.first); int l[n] = {}, r[n]; rep(i,n){ r[i] = q+1; } rep(_,30){ vector

v; rep(i,n){ if(l[i]==r[i])continue; int mid = (l[i]+r[i]) / 2 + 1; v.push_back(P(mid,i)); } if(v.size()==0)break; sort(v.begin(), v.end(), greater

()); UFinit(); int ite = 0; drep(i,q+2){ rep(j,G[i].size()){ unite(G[i][j].first, G[i][j].second); } while(ite