### BUGGY CODE ###

#coding:utf-8

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

# https://www.kumilog.net/entry/union-find#Python%E3%81%A7%E5%AE%9F%E8%A3%85
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

ufR=UnionFind(N+1)
ufT=UnionFind(N+1)
for i in range(K):
    p,q=map(int,raw_input().split())
    ufR.union(p,q)
for i in range(L):
    p,q=map(int,raw_input().split())
    ufT.union(p,q)    
from collections import defaultdict
R=defaultdict(set)
T=defaultdict(set)
for i in range(1,N+1):
    R[ufR.find(i)].add(i)
    T[ufT.find(i)].add(i)

ans={}
for i in range(1,N+1):
    r=R[ufR.find(i)]
    t=T[ufT.find(i)]
    if len(r)==0 or len(t)==0: continue
    s=r&t
    for c in s:
        ans[c]=len(s)
    r-=s
    t-=s
for i in range(1,N+1):
    print ans[i],
print("")    
    

### FIXED CODE ###

#coding:utf-8
import sys
N,K,L=map(int,raw_input().split())

# https://www.kumilog.net/entry/union-find#Python%E3%81%A7%E5%AE%9F%E8%A3%85
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

ufR=UnionFind(N+1)
ufT=UnionFind(N+1)
for i in range(K):
    p,q=map(int,sys.stdin.readline().split())
    ufR.union(p,q)
for i in range(L):
    p,q=map(int,sys.stdin.readline().split())
    ufT.union(p,q)    
from collections import defaultdict
R=defaultdict(set)
T=defaultdict(set)
for i in range(1,N+1):
    R[ufR.find(i)].add(i)
    T[ufT.find(i)].add(i)

ans=[0]*(N+1)
for i in range(1,N+1):
    if ans[i]!=0:continue
    r=R[ufR.find(i)]
    t=T[ufT.find(i)]
    if len(r)==0 or len(t)==0: continue
    s=r&t
    for c in s:
        ans[c]=str(len(s))
    r-=s
    t-=s

print(" ".join(ans[1:]))