local road={}
local rail={}
local size={}

local function init(n)
    for i=1,n do
        road[i]=i
        rail[i]=i
        size[i]=1
    end
end

local function root(x,list)
    return list[x]==x and x or root(list[x],list)
end

local function same(x,y,list)
    return root(x,list)==root(y,list)
end

local function unite(x,y,list)
    x=root(x,list)
    y=root(y,list)
    if x==y then
        return
    end
    if size[x]>size[y] then
        x,y=y,x
    end
    list[x]=y
    size[y]=size[y]+size[x]
end

local function getsize(x)
    return size[root(x,list)]
end

----------

local n,k,l=io.read("n","n","n")
init(n)

for i=1,k do
    local p,q=io.read("n","n")
    unite(p,q,road)
end

for i=1,l do
    local r,s=io.read("n","n")
    unite(r,s,rail)
end

local counter={}
for i=1,n do
    local key=root(i,road).." "..root(i,rail)
    counter[key]=(counter[key] or 0)+1
end

for i=1,n do
    local key=root(i,road).." "..root(i,rail)
    io.write(counter[key].." ")
end
print()