### BUGGY CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class UnionFind():
    def __init__(self, n):
        self.n = 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 size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, k, l = map(int, readline().split())
    uf1 = UnionFind(n + 1)
    uf2 = UnionFind(n + 1)

    for _ in range(k):
        p, q = map(int, readline().split())
        uf1.union(p, q)

    for _ in range(l):
        r, s = map(int, readline().split())
        uf2.union(r, s)

    res = [0] * (n + 1)
    for i in range(1, n + 1):
        if res[i] == 0:
            cnt = 0
            mem = []
            gm = uf2.members(i)
            for x in gm:
                if uf1.same(i, x):
                    cnt += 1
                    mem.append(x)
            for x in mem:
                res[x] = cnt

    print(*res[1:])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter, deque, defaultdict

    n, k, l = map(int, readline().split())

    edge1 = defaultdict(list)

    for _ in range(k):
        p, q = map(int, readline().split())
        edge1[p - 1].append(q - 1)
        edge1[q - 1].append(p - 1)

    a = [-1] * n
    que = deque()

    for i in range(n):
        if a[i] == -1:
            que.append(i)
            a[i] = i
            while que:
                cur = que.popleft()
                for nx in edge1[cur]:
                    if a[nx] == -1:
                        a[nx] = i
                        que.append(nx)

    edge2 = defaultdict(list)

    for _ in range(l):
        r, s = map(int, readline().split())
        edge2[r - 1].append(s - 1)
        edge2[s - 1].append(r - 1)

    b = [-1] * n
    que = deque()

    for i in range(n):
        if b[i] == -1:
            que.append(i)
            b[i] = i
            while que:
                cur = que.popleft()
                for nx in edge2[cur]:
                    if b[nx] == -1:
                        b[nx] = i
                        que.append(nx)

    c = Counter()
    for i in range(n):
        c[(a[i], b[i])] += 1

    res = [0] * n
    for i in range(n):
        res[i] = c[(a[i], b[i])]

    print(*res)


if __name__ == '__main__':
    main()