from collections import *;M=lambda:list(map(int,input().split()));r=range;n,k,l=M()

def f(m):

 *a,=r(n)

 def g(i):

  if a[i]==i:return i

  a[i]=g(a[i]);return a[i]

 for _ in r(m):p,q=M();a[g(q-1)]=g(p-1)

 return g

x,y=f(k),f(l);c=Counter((x(i),y(i))for i in r(n));print((*(c[x(i),y(i)]for i in r(n))))
from collections import *;M=lambda:list(map(int,input().split()));r=range;n,k,l=M()

def f(m):

 *a,=r(n)

 def g(i):

  if a[i]==i:return i

  a[i]=g(a[i]);return a[i]

 for _ in r(m):p,q=M();a[g(q-1)]=g(p-1)

 return [g(i) for i in r(n)]

z=[*list(zip(f(k),f(l)))];c=Counter(z);print((*(c[x]for x in z)))
from collections import *

M = lambda: list(map(int, input().split()))
r = range
n, k, l = M()


def f(m):
    (*a,) = r(n)

    def g(i):
        if a[i] == i:
            return i
        a[i] = g(a[i])
        return a[i]

    for _ in r(m):
        p, q = M()
        a[g(q - 1)] = g(p - 1)
    return g


x, y = f(k), f(l)
c = Counter((x(i), y(i)) for i in r(n))
print((*(c[x(i), y(i)] for i in r(n))))

from collections import *

M = lambda: list(map(int, input().split()))
r = range
n, k, l = M()


def f(m):
    (*a,) = r(n)

    def g(i):
        if a[i] == i:
            return i
        a[i] = g(a[i])
        return a[i]

    for _ in r(m):
        p, q = M()
        a[g(q - 1)] = g(p - 1)
    return [g(i) for i in r(n)]


z = [*list(zip(f(k), f(l)))]
c = Counter(z)
print((*(c[x] for x in z)))

-    return g +    return [g(i) for i in r(n)] -x, y = f(k), f(l) -c = Counter((x(i), y(i)) for i in r(n)) -print((*(c[x(i), y(i)] for i in r(n)))) +z = [*list(zip(f(k), f(l)))] +c = Counter(z) +print((*(c[x] for x in z)))