import Control.Monad (replicateM,mapM)
import Data.List

strToInt :: String -> [Int]
strToInt = map read . words

g :: [[Int]] -> [[Int]] -> Int -> Int
g list1 list2 x = h list1x list2x

 where
 foo :: [[Int]] -> Int -> Maybe [Int]
 foo list x = find (elem x) list
 
 list1x = foo list1 x
 list2x = foo list2 x
 
 h :: Maybe [Int] -> Maybe [Int] -> Int
 h (Just p) (Just q) = length $ intersect p q
 h _ Nothing = 0
 h Nothing _ = 0 

f :: [[Int]] -> [Int] -> [[Int]]
f oldList [x,y] = [listXY] ++ listZ

 where
 (listA,listZ) = partition (\list -> x `elem` list || y `elem` list) oldList
 listXY = sort $ foldl' union [] listA

main :: IO ()
main = do
 [n,k,l] <- fmap strToInt getLine 
 roadStr <- replicateM k getLine
 railStr <- replicateM l getLine
 
 let base = map (\x -> [x]) [1..n]
 let roads = sort $ foldl' f base (map strToInt roadStr)
 let rails = sort $ foldl' f base (map strToInt railStr)
 
 let answer = map (show . g roads rails) [1..n]
 mapM_ putStr $ zipWith (++) answer $ repeat " "