# -*- coding: utf-8 -*-

"""

Created on Wed Sep 11 11:26:39 2019

D - 連結 / Connectivity

実行時間制限: 2 sec / メモリ制限: 256 MB



配点 : 

400 点

@author: justwah

"""

from collections import Counter



class UnionFind:

    def __init__(self, N):

        self.rank = [0]*N

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

        self.n = N

        

    def root(self, x):

        if self.parent[x] == x:

            return x

        else:

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

            return self.parent[x]

        

    def merge(self, a, b):

        a = self.root(a)

        b = self.root(b)

        if a == b:

            return

        if self.rank[a] < self.rank[b]:

            self.parent[a] = b

        else:

            self.parent[b] = a

            if self.rank[a] == self.rank[b]:

                self.rank[a] +=1

                

    def same(self, a, b):

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





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



uf_road = UnionFind(n)

for _ in range(k):

    p, q = list(map(int, input().split()))

    uf_road.merge(p-1, q-1)



uf_rail = UnionFind(n)

for _ in range(l):

    r, s = list(map(int, input().split()))

    uf_rail.merge(r-1, s-1)

    

ctr = Counter()

for i in range(n):  # make a list to count number of cities that both road and rail-wise are in the same group

    r1 = uf_road.root(i)

    r2 = uf_rail.root(i)

    ctr[(r1,r2)] += 1



ans = []

for i in range(n): # print the group size of that city when looped

    r1 = uf_road.root(i)

    r2 = uf_rail.root(i)

    ans.append(ctr[(r1,r2)])



print((*ans))   # * is for unpack the list
def Find(x, par):

  if par[x] < 0:

    return x

  else:

    par[x] = Find(par[x], par)

    return par[x]



def Unite(x, y, par, rank):

  x = Find(x, par)

  y = Find(y, par)

  

  if x != y:

    if rank[x] < rank[y]:

      par[x] = y

    else:

      par[y] = x

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

        rank[x] += 1

    

def Same(x, y, par):

  return Find(x, par) == Find(y, par)

 

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

rpar = [-1]*n

tpar = [-1]*n

rrank = [0]*n

trank = [0]*n

 

for i in range(k):

  p, q = list(map(int, input().split()))

  p, q =p-1, q-1

  Unite(p,q, rpar, rrank) 



for i_ in range(l):

  p, q = list(map(int, input().split()))

  p, q =p-1, q-1

  Unite(p,q, tpar, trank)



d = {}

IDs = [0]*n

for j in range(n):

  ID = Find(j, rpar)+(Find(j, tpar)+1)*10**8

  IDs[j] = ID

  if ID in d:

    d[ID] += 1

  else:

    d[ID] = 1



ans = []

for j in range(n):

    ans.append(d[IDs[j]])

print((*ans))
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 11:26:39 2019
D - 連結 / Connectivity
実行時間制限: 2 sec / メモリ制限: 256 MB
配点 : 
400 点
@author: justwah
"""
from collections import Counter


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

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

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

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


n, k, l = list(map(int, input().split()))
uf_road = UnionFind(n)
for _ in range(k):
    p, q = list(map(int, input().split()))
    uf_road.merge(p - 1, q - 1)
uf_rail = UnionFind(n)
for _ in range(l):
    r, s = list(map(int, input().split()))
    uf_rail.merge(r - 1, s - 1)
ctr = Counter()
for i in range(
    n
):  # make a list to count number of cities that both road and rail-wise are in the same group
    r1 = uf_road.root(i)
    r2 = uf_rail.root(i)
    ctr[(r1, r2)] += 1
ans = []
for i in range(n):  # print the group size of that city when looped
    r1 = uf_road.root(i)
    r2 = uf_rail.root(i)
    ans.append(ctr[(r1, r2)])
print((*ans))  # * is for unpack the list

def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]


def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)
    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1


def Same(x, y, par):
    return Find(x, par) == Find(y, par)


n, k, l = list(map(int, input().split()))
rpar = [-1] * n
tpar = [-1] * n
rrank = [0] * n
trank = [0] * n
for i in range(k):
    p, q = list(map(int, input().split()))
    p, q = p - 1, q - 1
    Unite(p, q, rpar, rrank)
for i_ in range(l):
    p, q = list(map(int, input().split()))
    p, q = p - 1, q - 1
    Unite(p, q, tpar, trank)
d = {}
IDs = [0] * n
for j in range(n):
    ID = Find(j, rpar) + (Find(j, tpar) + 1) * 10**8
    IDs[j] = ID
    if ID in d:
        d[ID] += 1
    else:
        d[ID] = 1
ans = []
for j in range(n):
    ans.append(d[IDs[j]])
print((*ans))

-# -*- coding: utf-8 -*- -""" -Created on Wed Sep 11 11:26:39 2019 -D - 連結 / Connectivity -実行時間制限: 2 sec / メモリ制限: 256 MB -配点 : -400 点 -@author: justwah -""" -from collections import Counter +def Find(x, par): +    if par[x] < 0: +        return x +    else: +        par[x] = Find(par[x], par) +        return par[x] -class UnionFind: -    def __init__(self, N): -        self.rank = [0] * N -        self.parent = [i for i in range(N)] -        self.n = N +def Unite(x, y, par, rank): +    x = Find(x, par) +    y = Find(y, par) +    if x != y: +        if rank[x] < rank[y]: +            par[x] = y +        else: +            par[y] = x +            if rank[x] == rank[y]: +                rank[x] += 1 -    def root(self, x): -        if self.parent[x] == x: -            return x -        else: -            self.parent[x] = self.root(self.parent[x]) -            return self.parent[x] -    def merge(self, a, b): -        a = self.root(a) -        b = self.root(b) -        if a == b: -            return -        if self.rank[a] < self.rank[b]: -            self.parent[a] = b -        else: -            self.parent[b] = a -            if self.rank[a] == self.rank[b]: -                self.rank[a] += 1 - -    def same(self, a, b): -        return self.root(a) == self.roob(b) +def Same(x, y, par): +    return Find(x, par) == Find(y, par) -uf_road = UnionFind(n) -for _ in range(k): +rpar = [-1] * n +tpar = [-1] * n +rrank = [0] * n +trank = [0] * n +for i in range(k): -    uf_road.merge(p - 1, q - 1) -uf_rail = UnionFind(n) -for _ in range(l): -    r, s = list(map(int, input().split())) -    uf_rail.merge(r - 1, s - 1) -ctr = Counter() -for i in range( -    n -):  # make a list to count number of cities that both road and rail-wise are in the same group -    r1 = uf_road.root(i) -    r2 = uf_rail.root(i) -    ctr[(r1, r2)] += 1 +    p, q = p - 1, q - 1 +    Unite(p, q, rpar, rrank) +for i_ in range(l): +    p, q = list(map(int, input().split())) +    p, q = p - 1, q - 1 +    Unite(p, q, tpar, trank) +d = {} +IDs = [0] * n +for j in range(n): +    ID = Find(j, rpar) + (Find(j, tpar) + 1) * 10**8 +    IDs[j] = ID +    if ID in d: +        d[ID] += 1 +    else: +        d[ID] = 1 -for i in range(n):  # print the group size of that city when looped -    r1 = uf_road.root(i) -    r2 = uf_rail.root(i) -    ans.append(ctr[(r1, r2)]) -print((*ans))  # * is for unpack the list +for j in range(n): +    ans.append(d[IDs[j]]) +print((*ans))