from collections import Counter





class WeightedUnionFind():

    def __init__(self, n):

        self.parents = [-1] * n

        self.weight = [0] * n



    def find(self, x):

        if self.parents[x] < 0:

            return x

        else:

            self.weight[x] += self.weight[self.parents[x]]

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

            return self.parents[x]



    def union(self, x, y, w):

        rx = self.find(x)

        ry = self.find(y)



        if rx == ry:

            return



        if self.parents[rx] > self.parents[ry]:

            rx, ry = ry, rx

            x, y = y, x

            w = -w



        self.parents[rx] += self.parents[ry]

        self.parents[ry] = rx

        self.weight[ry] = + self.weight[x] - w - self.weight[y]



    def find_position(self, x):

        if self.parents[x] < 0:

            return 0

        else:

            return -self.weight[x] + self.find_position(self.parents[x])



    def diff(self, x, y):

        if self.find(x) != self.find(y):

            raise Exception('"{}" belongs to a different tree from "{}"'.format(x, y))

        return self.find_position(y) - self.find_position(x)





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

uf1 = WeightedUnionFind(N)

uf2 = WeightedUnionFind(N)

for _ in range(K):

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

    uf1.union(p - 1, q - 1, 0)



for _ in range(L):

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

    uf2.union(r - 1, s - 1, 0)



path = [None] * N

for i in range(N):

    path[i] = (uf1.find(i), uf2.find(i))



cnt = Counter(path)

for i in range(N - 1):

    print(cnt[path[i]], end=' ')

print(cnt[path[N - 1]])

class UnionFind():

    def __init__(self, n):

        self.parents = [-1] * n



    def find(self, x):

        if self.parents[x] < 0:

            return x

        else:

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

            return self.parents[x]



    def union(self, x, y):

        x = self.find(x)

        y = self.find(y)



        if x == y:

            return



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

            x, y = y, x



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

        self.parents[y] = x





def main():

    import sys

    from collections import Counter

    # readline = sys.stdin.readline

    readlines = sys.stdin.readlines

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

    uf1 = UnionFind(N)

    uf2 = UnionFind(N)



    IN = readlines()

    for i in range(K):

        p, q = list(map(int, IN[i].split()))

        p -= 1; q -= 1

        uf1.union(p, q)

    for j in range(K, K + L):

        r, s = list(map(int, IN[j].split()))

        r -= 1; s -= 1

        # if uf1.find(r) == uf1.find(s):

        uf2.union(r, s)

    

    # ans = []

    # for i in range(N):

    #     ans.append(-uf2.parents[uf2.find(i)])

    # print(*ans)

    path = []

    C = Counter()

    for i in range(N):

        pair = (uf1.find(i), uf2.find(i))

        path.append(pair)

        C[pair] += 1



    ans = []

    for i in range(N):

        ans.append(C[path[i]])

    print((*ans))





if __name__ == "__main__":

    main()

from collections import Counter


class WeightedUnionFind:
    def __init__(self, n):
        self.parents = [-1] * n
        self.weight = [0] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.weight[x] += self.weight[self.parents[x]]
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.parents[rx] > self.parents[ry]:
            rx, ry = ry, rx
            x, y = y, x
            w = -w
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx
        self.weight[ry] = +self.weight[x] - w - self.weight[y]

    def find_position(self, x):
        if self.parents[x] < 0:
            return 0
        else:
            return -self.weight[x] + self.find_position(self.parents[x])

    def diff(self, x, y):
        if self.find(x) != self.find(y):
            raise Exception('"{}" belongs to a different tree from "{}"'.format(x, y))
        return self.find_position(y) - self.find_position(x)


N, K, L = map(int, input().split())
uf1 = WeightedUnionFind(N)
uf2 = WeightedUnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    uf1.union(p - 1, q - 1, 0)
for _ in range(L):
    r, s = map(int, input().split())
    uf2.union(r - 1, s - 1, 0)
path = [None] * N
for i in range(N):
    path[i] = (uf1.find(i), uf2.find(i))
cnt = Counter(path)
for i in range(N - 1):
    print(cnt[path[i]], end=" ")
print(cnt[path[N - 1]])

class UnionFind:
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x


def main():
    import sys
    from collections import Counter

    # readline = sys.stdin.readline
    readlines = sys.stdin.readlines
    N, K, L = list(map(int, input().split()))
    uf1 = UnionFind(N)
    uf2 = UnionFind(N)
    IN = readlines()
    for i in range(K):
        p, q = list(map(int, IN[i].split()))
        p -= 1
        q -= 1
        uf1.union(p, q)
    for j in range(K, K + L):
        r, s = list(map(int, IN[j].split()))
        r -= 1
        s -= 1
        # if uf1.find(r) == uf1.find(s):
        uf2.union(r, s)
    # ans = []
    # for i in range(N):
    #     ans.append(-uf2.parents[uf2.find(i)])
    # print(*ans)
    path = []
    C = Counter()
    for i in range(N):
        pair = (uf1.find(i), uf2.find(i))
        path.append(pair)
        C[pair] += 1
    ans = []
    for i in range(N):
        ans.append(C[path[i]])
    print((*ans))


if __name__ == "__main__":
    main()

-from collections import Counter - - -class WeightedUnionFind: +class UnionFind: -        self.weight = [0] * n -            self.weight[x] += self.weight[self.parents[x]] -    def union(self, x, y, w): -        rx = self.find(x) -        ry = self.find(y) -        if rx == ry: +    def union(self, x, y): +        x = self.find(x) +        y = self.find(y) +        if x == y: -        if self.parents[rx] > self.parents[ry]: -            rx, ry = ry, rx +        if self.parents[x] > self.parents[y]: -            w = -w -        self.parents[rx] += self.parents[ry] -        self.parents[ry] = rx -        self.weight[ry] = +self.weight[x] - w - self.weight[y] - -    def find_position(self, x): -        if self.parents[x] < 0: -            return 0 -        else: -            return -self.weight[x] + self.find_position(self.parents[x]) - -    def diff(self, x, y): -        if self.find(x) != self.find(y): -            raise Exception('"{}" belongs to a different tree from "{}"'.format(x, y)) -        return self.find_position(y) - self.find_position(x) +        self.parents[x] += self.parents[y] +        self.parents[y] = x -N, K, L = map(int, input().split()) -uf1 = WeightedUnionFind(N) -uf2 = WeightedUnionFind(N) -for _ in range(K): -    p, q = map(int, input().split()) -    uf1.union(p - 1, q - 1, 0) -for _ in range(L): -    r, s = map(int, input().split()) -    uf2.union(r - 1, s - 1, 0) -path = [None] * N -for i in range(N): -    path[i] = (uf1.find(i), uf2.find(i)) -cnt = Counter(path) -for i in range(N - 1): -    print(cnt[path[i]], end=" ") -print(cnt[path[N - 1]]) +def main(): +    import sys +    from collections import Counter + +    # readline = sys.stdin.readline +    readlines = sys.stdin.readlines +    N, K, L = list(map(int, input().split())) +    uf1 = UnionFind(N) +    uf2 = UnionFind(N) +    IN = readlines() +    for i in range(K): +        p, q = list(map(int, IN[i].split())) +        p -= 1 +        q -= 1 +        uf1.union(p, q) +    for j in range(K, K + L): +        r, s = list(map(int, IN[j].split())) +        r -= 1 +        s -= 1 +        # if uf1.find(r) == uf1.find(s): +        uf2.union(r, s) +    # ans = [] +    # for i in range(N): +    #     ans.append(-uf2.parents[uf2.find(i)]) +    # print(*ans) +    path = [] +    C = Counter() +    for i in range(N): +        pair = (uf1.find(i), uf2.find(i)) +        path.append(pair) +        C[pair] += 1 +    ans = [] +    for i in range(N): +        ans.append(C[path[i]]) +    print((*ans)) + + +if __name__ == "__main__": +    main()