N, K, L = [int(_) for _ in input().split()]





def find(a, x):

    if a[x] != x:

        a[x] = find(a, a[x])

    return a[x]





def unite(a, x, y):

    x = find(a, x)

    y = find(a, y)

    if x != y:

        a[x] = max(x, y)

        a[y] = a[x]





a_road = [i for i in range(N)]

for _ in range(K):

    p, q = [int(_) - 1 for _ in input().split()]

    unite(a_road, p, q)

a_railway = [i for i in range(N)]

for _ in range(L):

    r, s = [int(_) - 1 for _ in input().split()]

    unite(a_railway, r, s)

memo = {}

for i in range(N):

    memo[find(a_road, i), find(a_railway, i)] = memo.get(

        (find(a_road, i), find(a_railway, i)), 0) + 1



print((' '.join(str(memo[find(a_road, i), find(a_railway, i)])

               for i in range(N))))

N, K, L = [int(_) for _ in input().split()]





def find(a, x):

    if a[x] != x:

        a[x] = find(a, a[x])

    return a[x]





def unite(a, x, y):

    x = find(a, x)

    y = find(a, y)

    if x != y:

        a[x] = min(x, y)

        a[y] = a[x]





a_road = [i for i in range(N)]

for _ in range(K):

    p, q = [int(_) - 1 for _ in input().split()]

    unite(a_road, p, q)

a_railway = [i for i in range(N)]

for _ in range(L):

    r, s = [int(_) - 1 for _ in input().split()]

    unite(a_railway, r, s)

memo = {}

for i in range(N):

    memo[find(a_road, i), find(a_railway, i)] = memo.get(

        (find(a_road, i), find(a_railway, i)), 0) + 1



print((' '.join(str(memo[a_road[i], a_railway[i]]) for i in range(N))))

N, K, L = [int(_) for _ in input().split()]


def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]


def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    if x != y:
        a[x] = max(x, y)
        a[y] = a[x]


a_road = [i for i in range(N)]
for _ in range(K):
    p, q = [int(_) - 1 for _ in input().split()]
    unite(a_road, p, q)
a_railway = [i for i in range(N)]
for _ in range(L):
    r, s = [int(_) - 1 for _ in input().split()]
    unite(a_railway, r, s)
memo = {}
for i in range(N):
    memo[find(a_road, i), find(a_railway, i)] = (
        memo.get((find(a_road, i), find(a_railway, i)), 0) + 1
    )
print((" ".join(str(memo[find(a_road, i), find(a_railway, i)]) for i in range(N))))

N, K, L = [int(_) for _ in input().split()]


def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]


def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    if x != y:
        a[x] = min(x, y)
        a[y] = a[x]


a_road = [i for i in range(N)]
for _ in range(K):
    p, q = [int(_) - 1 for _ in input().split()]
    unite(a_road, p, q)
a_railway = [i for i in range(N)]
for _ in range(L):
    r, s = [int(_) - 1 for _ in input().split()]
    unite(a_railway, r, s)
memo = {}
for i in range(N):
    memo[find(a_road, i), find(a_railway, i)] = (
        memo.get((find(a_road, i), find(a_railway, i)), 0) + 1
    )
print((" ".join(str(memo[a_road[i], a_railway[i]]) for i in range(N))))

-        a[x] = max(x, y) +        a[x] = min(x, y) -print((" ".join(str(memo[find(a_road, i), find(a_railway, i)]) for i in range(N)))) +print((" ".join(str(memo[a_road[i], a_railway[i]]) for i in range(N))))