import Control.Monad (replicateM,mapM)
import Data.List (foldl',union,intersect)
import qualified Data.Map as Map
type Mapp = Map.Map Int [Int]

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

f :: Mapp -> [Int] -> Mapp
f oldMap [x,y] = if Map.size mapXY == 1 then oldMap else newMap

 where
 mapXY = Map.filter (\list -> x `elem` list || y `elem` list) oldMap
 newList = Map.fold union [] mapXY
 newMapXY = Map.fromList $ map (\k -> (k,newList)) newList
 newMap = Map.union newMapXY oldMap

g :: Mapp -> Mapp -> Int -> Int
g map1 map2 x = fun (Map.lookup x map1) (Map.lookup x map2)

 where
 fun :: Maybe [Int] -> Maybe [Int] -> Int
 fun (Just p) (Just q) = length $ intersect p q
 fun Nothing _ = 0
 fun _ Nothing = 0

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