### BUGGY CODE ###

class UnionFindTree():
    def __init__(self, values=[]):
        self.__parent_of = {}
        self.__rank_of = {}
        self.__size = {}
        for value in values:
            self.add(value)

    def add(self, value):
        if value in self.__parent_of:
            raise RuntimeError("Dupulicated Value Added")
        self.__parent_of[value] = None
        self.__rank_of[value] = 0
        self.__size[value] = 1

    def __root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.__root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.__root(a)
        r2 = self.__root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.__root(a) == self.__root(b)

    def size(self, a):
        return self.__size[self.__root(a)]

    def groups(self):
        groups = {}
        for k in self.__parent_of.keys():
            r = self.__root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    N, K, L = map(int, input().split())
    uft = UnionFindTree(range(N))
    for _ in range(K):
        p, q = map(int, input().split())
        uft.unite(p-1, q-1)
    uft2 = UnionFindTree(range(N))
    for _ in range(L):
        r, s = map(int, input().split())
        uft2.unite(r-1, s-1)
    pair = [(0, 0)] * N
    cnt = {}
    for i in range(N):
        r1 = uft._UnionFindTree__root(i)
        r2 = uft2._UnionFindTree__root(i)
        if (r1, r2) not in cnt:
            cnt[(r1, r2)] = 0
        cnt[(r1, r2)] += 1
    ans = [0] * N
    for i in range(N):
        r1 = uft._UnionFindTree__root(i)
        r2 = uft2._UnionFindTree__root(i)
        ans[i] = cnt[(r1, r2)]
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


### FIXED CODE ###

class UnionFindTree():
    def __init__(self, values=[]):
        self.__parent_of = {}
        self.__rank_of = {}
        for value in values:
            self.add(value)

    def add(self, value):
        if value in self.__parent_of:
            raise RuntimeError("Dupulicated Value Added")
        self.__parent_of[value] = None
        self.__rank_of[value] = 0

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
            else:
                self.__parent_of[r2] = r1
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1


def main():
    N, K, L = map(int, input().split())
    uft = UnionFindTree(range(N))
    for _ in range(K):
        p, q = map(int, input().split())
        uft.unite(p-1, q-1)
    uft2 = UnionFindTree(range(N))
    for _ in range(L):
        r, s = map(int, input().split())
        uft2.unite(r-1, s-1)
    pair = [(0, 0)] * N
    cnt = {}
    for i in range(N):
        p = (uft.root(i), uft2.root(i))
        if p not in cnt:
            cnt[p] = 0
        cnt[p] += 1
        pair[i] = p
    ans = [0] * N
    for i in range(N):
        ans[i] = cnt[pair[i]]
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()