output_description: Print N integers. The i-th of them should represent the number of the cities
  connected to the i-th city by both roads and railways.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N K L
      p_1 q_1
      :
      p_K q_K
      r_1 s_1
      :
      r_L s_L
attempt: #include "bits/stdc++.h"
  #define rep(i,n) for(int i=0;i<n;i++)
  using namespace std;
  
  typedef long long ll;
  
  const int MAX_N = 200001;
  int par[MAX_N];
  int rnk[MAX_N];
  
  void init(int n) {
      rep(i,n) {
          par[i] = i;
          rnk[i] = 0;
      }
  }
  
  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;
      if (rnk[x] < rnk[y]) {
          par[x] = y;
      } else {
          par[y] = x;
          if (rnk[x] == rnk[y]) rnk[x]++;
      }
  }
  
  bool same(int x, int y) {
      return find(x) == find(y);
  }
  
  void solve() {
      int N, K, L, p, q;
      cin >> N >> K >> L;
      init(N);
      rep(i,K) {
          cin >> p >> q;
          unite(p - 1, q - 1);
      }
      int roads[N];
      rep(i,N) roads[i] = find(i);
      init(N);
      rep(i,L) {
          cin >> p >> q;
          unite(p - 1, q - 1);
      }
      map<pair<int, int>, int> d;
      rep(i,N) d[make_pair(roads[i], find(i))]++;
      rep(i,N) cout << d[make_pair(roads[i], find(i))] << " ";
      cout << endl;
      return;
  }
  
  int main() {
      solve();
  }
problem_description: Statement
  
  There are N cities. There are also K roads and L railways, extending between
  the cities. The i-th road bidirectionally connects the p_i-th and q_i-th
  cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th
  cities. No two roads connect the same pair of cities. Similarly, no two
  railways connect the same pair of cities.
  
  We will say city A and B are _connected by roads_ if city B is reachable from
  city A by traversing some number of roads. Here, any city is considered to be
  connected to itself by roads. We will also define _connectivity by railways_
  similarly.
  
  For each city, find the number of the cities connected to that city by both
  roads and railways.
samples: [{"input": "4 3 1\n    1 2\n    2 3\n    3 4\n    2 3", "output": "1 2 2 1\n    \n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers\nfor the cities are 1, 2, 2 and 1, respectively.\n\n* * *"}, {"input": "4 2 2\n    1 2\n    2 3\n    1 4\n    2 3", "output": "1 2 2 1\n    \n\n* * *"}, {"input": "7 4 4\n    1 2\n    2 3\n    2 5\n    6 7\n    3 5\n    4 5\n    3 4\n    6 7", "output": "1 1 2 1 2 2 2"}]