from collections import Counter

N,K,L = list(map(int,input().split()))

P = [tuple(map(int,input().split())) for i in range(K)]

R = [tuple(map(int,input().split())) for i in range(L)]



class UnionFind:

    def __init__(self,N):

        self.parent = [i for i in range(N)]

        self.rank = [0] * N

        self.count = 0

    def root(self,a):

        if self.parent[a] == a:

            return a

        else:

            self.parent[a] = self.root(self.parent[a])

            return self.parent[a]

    def is_same(self,a,b):

        return self.root(a) == self.root(b)

    def unite(self,a,b):

        ra = self.root(a)

        rb = self.root(b)

        if ra == rb: return

        if self.rank[ra] < self.rank[rb]:

            self.parent[ra] = rb

        else:

            self.parent[rb] = ra

            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1

        self.count += 1



uf1 = UnionFind(N)

for p,q in P:

    p,q = p-1,q-1

    if uf1.is_same(p,q): continue

    uf1.unite(p,q)



uf2 = UnionFind(N)

for r,s in R:

    r,s = r-1,s-1

    if uf2.is_same(r,s): continue

    uf2.unite(r,s)



pairs = Counter()

for i in range(N):

    a = uf1.root(i)

    b = uf2.root(i)

    pairs[(a,b)] += 1



ans = []

for i in range(N):

    a = uf1.root(i)

    b = uf2.root(i)

    ans.append(pairs[(a,b)])

print((*ans))
N,K,L = list(map(int,input().split()))

PQ = [tuple(map(int,input().split())) for i in range(K)]

RS = [tuple(map(int,input().split())) for i in range(L)]



class UnionFind:

    def __init__(self,N):

        self.parent = [i for i in range(N)]

        self.rank = [0] * N

        self.count = 0

    def root(self,a):

        if self.parent[a] == a:

            return a

        else:

            self.parent[a] = self.root(self.parent[a])

            return self.parent[a]

    def is_same(self,a,b):

        return self.root(a) == self.root(b)

    def unite(self,a,b):

        ra = self.root(a)

        rb = self.root(b)

        if ra == rb: return

        if self.rank[ra] < self.rank[rb]:

            self.parent[ra] = rb

        else:

            self.parent[rb] = ra

            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1

        self.count += 1



roads = UnionFind(N)

rails = UnionFind(N)

for p,q in PQ:

    p,q = p-1,q-1

    roads.unite(p,q)

for r,s in RS:

    r,s = r-1,s-1

    rails.unite(r,s)

for i in range(N):

    roads.root(i)

    rails.root(i)



from collections import Counter

ctr = Counter()

for i in range(N):

    ctr[(roads.parent[i], rails.parent[i])] += 1

ans = []

for i in range(N):

    ans.append(ctr[(roads.parent[i], rails.parent[i])])

print((*ans))
from collections import Counter

N, K, L = list(map(int, input().split()))
P = [tuple(map(int, input().split())) for i in range(K)]
R = [tuple(map(int, input().split())) for i in range(L)]


class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0

    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1


uf1 = UnionFind(N)
for p, q in P:
    p, q = p - 1, q - 1
    if uf1.is_same(p, q):
        continue
    uf1.unite(p, q)
uf2 = UnionFind(N)
for r, s in R:
    r, s = r - 1, s - 1
    if uf2.is_same(r, s):
        continue
    uf2.unite(r, s)
pairs = Counter()
for i in range(N):
    a = uf1.root(i)
    b = uf2.root(i)
    pairs[(a, b)] += 1
ans = []
for i in range(N):
    a = uf1.root(i)
    b = uf2.root(i)
    ans.append(pairs[(a, b)])
print((*ans))

N, K, L = list(map(int, input().split()))
PQ = [tuple(map(int, input().split())) for i in range(K)]
RS = [tuple(map(int, input().split())) for i in range(L)]


class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0

    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1


roads = UnionFind(N)
rails = UnionFind(N)
for p, q in PQ:
    p, q = p - 1, q - 1
    roads.unite(p, q)
for r, s in RS:
    r, s = r - 1, s - 1
    rails.unite(r, s)
for i in range(N):
    roads.root(i)
    rails.root(i)
from collections import Counter

ctr = Counter()
for i in range(N):
    ctr[(roads.parent[i], rails.parent[i])] += 1
ans = []
for i in range(N):
    ans.append(ctr[(roads.parent[i], rails.parent[i])])
print((*ans))

-from collections import Counter - -P = [tuple(map(int, input().split())) for i in range(K)] -R = [tuple(map(int, input().split())) for i in range(L)] +PQ = [tuple(map(int, input().split())) for i in range(K)] +RS = [tuple(map(int, input().split())) for i in range(L)] -uf1 = UnionFind(N) -for p, q in P: +roads = UnionFind(N) +rails = UnionFind(N) +for p, q in PQ: -    if uf1.is_same(p, q): -        continue -    uf1.unite(p, q) -uf2 = UnionFind(N) -for r, s in R: +    roads.unite(p, q) +for r, s in RS: -    if uf2.is_same(r, s): -        continue -    uf2.unite(r, s) -pairs = Counter() +    rails.unite(r, s) -    a = uf1.root(i) -    b = uf2.root(i) -    pairs[(a, b)] += 1 +    roads.root(i) +    rails.root(i) +from collections import Counter + +ctr = Counter() +for i in range(N): +    ctr[(roads.parent[i], rails.parent[i])] += 1 -    a = uf1.root(i) -    b = uf2.root(i) -    ans.append(pairs[(a, b)]) +    ans.append(ctr[(roads.parent[i], rails.parent[i])])