#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import*\n"
"class UnionFind():\n"
"    def __init__(self,size):\n"
"        self.table=[-1]*size\n"
"    def root(self,x):\n"
"        while self.table[x]>=0:\n"
"            x=self.table[x]\n"
"        return x\n"
"    def unite(self,x,y):\n"
"        s1=self.root(x)\n"
"        s2=self.root(y)\n"
"        if s1!=s2:\n"
"            if self.table[s1]>self.table[s2]:\n"
"                s1,s2=s2,s1\n"
"            self.table[s1]+=self.table[s2]\n"
"            self.table[s2]=s1\n"
"        return\n"
"    def same(self,x,y):\n"
"        return self.root(x)==self.root(y)\n"
"    def size(self,x):\n"
"        return -self.table[self.root(x)]\n"
"input=open(0).readline\n"
"n,k,l=map(int,input().split())\n"
"u=UnionFind(n)\n"
"v=UnionFind(n)\n"
"for _ in range(k):\n"
"    p,q=map(int,input().split())\n"
"    u.unite(p-1,q-1)\n"
"for _ in range(l):\n"
"    r,s=map(int,input().split())\n"
"    v.unite(r-1,s-1)\n"
"d=defaultdict(int)\n"
"a=[]\n"
"for i in range(n):\n"
"    t=(u.root(i),v.root(i))\n"
"    d[t]+=1\n"
"    a.append(t)\n"
"print(*[d[i]for i in a])\n"
"\"";
  system(s);
  return 0;
}            