#include <bits/stdc++.h>

using namespace std;

struct UnionFind
{
  vector<int> data;
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }  
  int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
  bool same(int x, int y) { return find(x) == find(y); }  
  int unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] < data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return -data[x];
  }
};

int main()
{
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind road(N), line(N);
  for(int i = 0; i < K; i++) {
    int p, q;
    cin >> p >> q; p--, q--;
    road.unite(p, q);
  }
  for(int i = 0; i < L; i++) {
    int r, s;
    cin >> r >> s; r--, s--;
    line.unite(r, s);
  }
  typedef pair<int, int> P;
  map<P, int> cnt;
  for(int i = 0; i < N; i++) {
    cnt[P(road.find(i), line.find(i))]++;
  }
  for(int i = 0; i < N; i++) {
    if(i) cout << " ";
    cout << cnt[P(road.find(i), line.find(i))];
  }
  cout << endl;
  return 0;
}
