#include using namespace std; //#define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define vec vector #define mat vector > #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef pair pll; typedef long double ld; typedef complex comp; const ll INF=1e9+7; const ll inf=INF*INF; const ll MOD=1e9+7; const ll mod=MOD; const ll MAX=200010; const double PI=acos(-1.0); //Union-Find木 struct UnionFind { vector< int > data; UnionFind() = default; explicit UnionFind(size_t sz) : data(sz, -1) {} bool unite(int x, int y) { x = find(x), y = find(y); if(x == y) return false; if(data[x] > data[y]) swap(x, y); data[x] += data[y]; data[y] = x; return true; } int find(int k) { if(data[k] < 0) return (k); return data[k] = find(data[k]); } int size(int k) { return -data[find(k)]; } bool same(int x, int y) { return find(x) == find(y); } }; signed main(){ ll n,d,w;cin>>n>>d>>w; UnionFind uf(n); ll ans=0; rep(i,d){ ll a,b;cin>>a>>b; a--;b--; uf.unite(a,b); } UnionFind uf2(n); rep(i,w){ ll a,b;cin>>a>>b; a--;b--; uf2.unite(a,b); } vector >st(n); rep(i,n){ ll rd=uf.find(i); ll rw=uf2.find(i); if(!st[rd].count(rw)){ st[rd].insert(rw); ans+=uf.size(rd)*uf2.size(rw); } } cout<