class UnionFind{
  int[] root;
  this(int n){
    root.length=n;
    foreach(i; 0..n) root[i]=i;
  }
  int find(int x){
    if(x==root[x]) return x;
    else return root[x]=find(root[x]);
  }
  void merge(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    root[x]=y;
  }
}

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, k, l; rd(n, k, l);
  auto s1=new UnionFind(n), s2=new UnionFind(n);
  foreach(_; 0..k){
    int a, b; rd(a, b);
    s1.merge(a-1, b-1);
  }
  foreach(_; 0..l){
    int a, b; rd(a, b);
    s2.merge(a-1, b-1);
  }
  struct Pair{int fi, se;}
  int[Pair] freq;
  foreach(i; 0..n){
    auto pair=Pair(s1.find(i), s2.find(i));
    if(pair in freq) freq[pair]++;
    else freq[pair]=1;
  }
  foreach(i; 0..n){
    writeln(freq[Pair(s1.find(i), s2.find(i))]);
  }

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}
