#UnionFindクラス

class UnionFind(object):



  def __init__(self, n=1):

    self.par = [i for i in range(n)]

    self.rank = [0 for _ in range(n)]



  def find(self, x):

        if self.par[x] == x:

            return x

        else:

            self.par[x] = self.find(self.par[x])

            return self.par[x]

  

  # xとyの根を結合させる

  def union(self, x, y):

    x = self.find(x)

    y = self.find(y)

    if x != y:

      if self.rank[x] < self.rank[y]:

        x, y = y, x

      if self.rank[x] == self.rank[y]:

        self.rank[x] += 1

      self.par[y] = x

  

  # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）

  def is_same(self, x, y):

    return self.find(x) == self.find(y)



n,k,l = list(map(int,input().split()))

    

uf_road = UnionFind(n)

uf_rail = UnionFind(n)

for i in range(k):

  tmp1,tmp2 = list(map(int,input().split()))

  uf_road.union(tmp1-1,tmp2-1)

  

for i in range(l):

  tmp1,tmp2 = list(map(int,input().split()))

  uf_rail.union(tmp1-1,tmp2-1)



memo = {}

for i in range(n):

  if str(uf_rail.find(i))+" "+str(uf_road.find(i)) not in memo:

    memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))] = 1

  else:

    memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))] += 1



for i in range(n):

  print((memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))]))
class UnionFind:

    """素集合を木構造として管理する"""

    def __init__(self, n):

        self.parent = [-1] * n

        self.cnt = n



    def root(self, x):

        """要素xの根を求める"""

        if self.parent[x] < 0:

            return x

        else:

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

            return self.parent[x]



    def merge(self, x, y):

        """要素xを含む集合と要素yを含む集合を統合する"""

        x = self.root(x)

        y = self.root(y)

        if x == y:

            return

        if self.parent[x] > self.parent[y]:

            x, y = y, x

        self.parent[x] += self.parent[y]

        self.parent[y] = x

        self.cnt -= 1



    def is_same(self, x, y):

        """要素x, yが同じ集合に属するかどうかを求める"""

        return self.root(x) == self.root(y)



    def get_size(self, x):

        """要素xを含む集合の要素数を求める"""

        return -self.parent[self.root(x)]





n, k, l = list(map(int, input().split()))

info_k = [list(map(int, input().split())) for i in range(k)]

info_l = [list(map(int, input().split())) for i in range(l)]



ufk = UnionFind(n)

ufl = UnionFind(n)

uf_total = UnionFind(n)



for a, b in info_k:

    a -= 1

    b -= 1

    ufk.merge(a, b)



for a, b in info_l:

    a -= 1

    b -= 1

    ufl.merge(a, b)



pair_cnt = {}

for i in range(n):

    if (ufk.root(i), ufl.root(i)) not in pair_cnt:

        pair_cnt[ufk.root(i), ufl.root(i)] = 1

    else:

        pair_cnt[ufk.root(i), ufl.root(i)] += 1



ans = [pair_cnt[ufk.root(i), ufl.root(i)] for i in range(n)]

print((*ans))
# UnionFindクラス
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # xとyの根を結合させる
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）
    def is_same(self, x, y):
        return self.find(x) == self.find(y)


n, k, l = list(map(int, input().split()))
uf_road = UnionFind(n)
uf_rail = UnionFind(n)
for i in range(k):
    tmp1, tmp2 = list(map(int, input().split()))
    uf_road.union(tmp1 - 1, tmp2 - 1)
for i in range(l):
    tmp1, tmp2 = list(map(int, input().split()))
    uf_rail.union(tmp1 - 1, tmp2 - 1)
memo = {}
for i in range(n):
    if str(uf_rail.find(i)) + " " + str(uf_road.find(i)) not in memo:
        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] = 1
    else:
        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] += 1
for i in range(n):
    print((memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))]))

class UnionFind:
    """素集合を木構造として管理する"""

    def __init__(self, n):
        self.parent = [-1] * n
        self.cnt = n

    def root(self, x):
        """要素xの根を求める"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を統合する"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1

    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める"""
        return self.root(x) == self.root(y)

    def get_size(self, x):
        """要素xを含む集合の要素数を求める"""
        return -self.parent[self.root(x)]


n, k, l = list(map(int, input().split()))
info_k = [list(map(int, input().split())) for i in range(k)]
info_l = [list(map(int, input().split())) for i in range(l)]
ufk = UnionFind(n)
ufl = UnionFind(n)
uf_total = UnionFind(n)
for a, b in info_k:
    a -= 1
    b -= 1
    ufk.merge(a, b)
for a, b in info_l:
    a -= 1
    b -= 1
    ufl.merge(a, b)
pair_cnt = {}
for i in range(n):
    if (ufk.root(i), ufl.root(i)) not in pair_cnt:
        pair_cnt[ufk.root(i), ufl.root(i)] = 1
    else:
        pair_cnt[ufk.root(i), ufl.root(i)] += 1
ans = [pair_cnt[ufk.root(i), ufl.root(i)] for i in range(n)]
print((*ans))

-# UnionFindクラス -class UnionFind(object): -    def __init__(self, n=1): -        self.par = [i for i in range(n)] -        self.rank = [0 for _ in range(n)] +class UnionFind: +    """素集合を木構造として管理する""" -    def find(self, x): -        if self.par[x] == x: +    def __init__(self, n): +        self.parent = [-1] * n +        self.cnt = n + +    def root(self, x): +        """要素xの根を求める""" +        if self.parent[x] < 0: -            self.par[x] = self.find(self.par[x]) -            return self.par[x] +            self.parent[x] = self.root(self.parent[x]) +            return self.parent[x] -    # xとyの根を結合させる -    def union(self, x, y): -        x = self.find(x) -        y = self.find(y) -        if x != y: -            if self.rank[x] < self.rank[y]: -                x, y = y, x -            if self.rank[x] == self.rank[y]: -                self.rank[x] += 1 -            self.par[y] = x +    def merge(self, x, y): +        """要素xを含む集合と要素yを含む集合を統合する""" +        x = self.root(x) +        y = self.root(y) +        if x == y: +            return +        if self.parent[x] > self.parent[y]: +            x, y = y, x +        self.parent[x] += self.parent[y] +        self.parent[y] = x +        self.cnt -= 1 -    # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False） -        return self.find(x) == self.find(y) +        """要素x, yが同じ集合に属するかどうかを求める""" +        return self.root(x) == self.root(y) + +    def get_size(self, x): +        """要素xを含む集合の要素数を求める""" +        return -self.parent[self.root(x)] -uf_road = UnionFind(n) -uf_rail = UnionFind(n) -for i in range(k): -    tmp1, tmp2 = list(map(int, input().split())) -    uf_road.union(tmp1 - 1, tmp2 - 1) -for i in range(l): -    tmp1, tmp2 = list(map(int, input().split())) -    uf_rail.union(tmp1 - 1, tmp2 - 1) -memo = {} +info_k = [list(map(int, input().split())) for i in range(k)] +info_l = [list(map(int, input().split())) for i in range(l)] +ufk = UnionFind(n) +ufl = UnionFind(n) +uf_total = UnionFind(n) +for a, b in info_k: +    a -= 1 +    b -= 1 +    ufk.merge(a, b) +for a, b in info_l: +    a -= 1 +    b -= 1 +    ufl.merge(a, b) +pair_cnt = {} -    if str(uf_rail.find(i)) + " " + str(uf_road.find(i)) not in memo: -        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] = 1 +    if (ufk.root(i), ufl.root(i)) not in pair_cnt: +        pair_cnt[ufk.root(i), ufl.root(i)] = 1 -        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] += 1 -for i in range(n): -    print((memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))])) +        pair_cnt[ufk.root(i), ufl.root(i)] += 1 +ans = [pair_cnt[ufk.root(i), ufl.root(i)] for i in range(n)] +print((*ans))