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





class UFT():

    def __init__(self):

        self.par = {}

        self.rank = {}

        for i in range(1, N + 1):

            self.par[i] = i

            self.rank[i] = 0



    def find(self, x):

        if self.par[x] == x:

            return x

        else:

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

            return self.par[x]



    def unite(self, x, y):

        x = self.find(x)

        y = self.find(y)

        if x == y:

            return



        if self.rank[x] < self.rank[y]:

            self.par[x] = y

        else:

            self.par[y] = x

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

                self.rank[x] += 1



    def same(self, x, y):

        return self.find(x) == self.find(y)





Road = UFT()

for _ in range(K):

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

    Road.unite(p, q)

Railway = UFT()

for _ in range(L):

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

    Railway.unite(r, s)

memo = {}

for i in range(1, N + 1):

    memo[Road.find(i), Railway.find(i)] = memo.get(

        (Road.find(i), Railway.find(i)), 0) + 1

print((' '.join(str(memo[Road.find(i), Railway.find(i)])

               for i in range(1, N + 1))))

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





class UFT():

    def __init__(self):

        self.par = [i for i in range(N + 1)]

        self.rank = [0] * (N + 1)



    def find(self, x):

        if self.par[x] == x:

            return x

        else:

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

            return self.par[x]



    def unite(self, x, y):

        x = self.find(x)

        y = self.find(y)

        if x == y:

            return



        if self.rank[x] < self.rank[y]:

            self.par[x] = y

        else:

            self.par[y] = x

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

                self.rank[x] += 1



    def same(self, x, y):

        return self.find(x) == self.find(y)





Road = UFT()

for _ in range(K):

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

    Road.unite(p, q)

Railway = UFT()

for _ in range(L):

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

    Railway.unite(r, s)

memo = {}

for i in range(1, N + 1):

    memo[Road.find(i), Railway.find(i)] = memo.get(

        (Road.find(i), Railway.find(i)), 0) + 1

print((' '.join(str(memo[Road.find(i), Railway.find(i)])

               for i in range(1, N + 1))))

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


class UFT:
    def __init__(self):
        self.par = {}
        self.rank = {}
        for i in range(1, N + 1):
            self.par[i] = i
            self.rank[i] = 0

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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


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

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


class UFT:
    def __init__(self):
        self.par = [i for i in range(N + 1)]
        self.rank = [0] * (N + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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


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

-        self.par = {} -        self.rank = {} -        for i in range(1, N + 1): -            self.par[i] = i -            self.rank[i] = 0 +        self.par = [i for i in range(N + 1)] +        self.rank = [0] * (N + 1)