#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for(int i=0;i<n;i++) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]); 
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};
int main(){
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind road(n),train(n);
  for(int i=0;i<k;i++){
    int p,q;
    cin >> p >> q;
    road.unite(--p,--q);
  }
  for(int i=0;i<l;i++){
    int p,q;
    cin >> p >> q;
    train.unite(--p,--q);
  }
  map<pair<int,int>,int> mp;
  for(int i=0;i<n;i++) mp[{train.find(i),road.find(i)}]++;
  for(int i=0;i<n;i++) cout << mp[{train.find(i),road.find(i)}] << " \n"[i==n-1];
}