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:

    # rankの低い方を高い方につなげる

    if rank[x] < rank[y]:

      par[y] += par[x]

      par[x] = y

    else:

      par[x] += par[y]

      par[y] = x

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

        rank[x] += 1

    

def Same(x, y, par):

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

 

def Size(x, par):

  return -par[Find(x)]



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



for j_ in range(n):

  print((d[IDs[j_]]))



    







  

  

    

    
import sys

input = sys.stdin.readline



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:

    # rankの低い方を高い方につなげる

    if rank[x] < rank[y]:

      par[y] += par[x]

      par[x] = y

    else:

      par[x] += par[y]

      par[y] = x

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

        rank[x] += 1

    

def Same(x, y, par):

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

 

def Size(x, par):

  return -par[Find(x)]



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



for j_ in range(n):

  print((d[IDs[j_]]))

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:
        # rankの低い方を高い方につなげる
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1


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


def Size(x, par):
    return -par[Find(x)]


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
for j_ in range(n):
    print((d[IDs[j_]]))

import sys

input = sys.stdin.readline


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:
        # rankの低い方を高い方につなげる
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1


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


def Size(x, par):
    return -par[Find(x)]


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
for j_ in range(n):
    print((d[IDs[j_]]))

+import sys + +input = sys.stdin.readline + +