import Control.Monad (replicateM)
import Data.List (intersperse, (\\), intersect, find)

main :: IO ()
main = do
  [n, k, l] <- fmap (map rInt . words) $ getLine
  ks <- fmap (map (map rInt . words)) $ getNLine_ k
  ls <- fmap (map (map rInt . words)) $ getNLine_ l
  putStrLn $
    (concat . intersperse " " . map (show . answer (renketu n ks) (renketu n ls))) [1..n]

-- 道路と線路それぞれのｋが含まれているグループで一致する都市数
answer :: [[Int]] -> [[Int]] -> Int -> Int
answer ks ls k = length $ intersect (func ks) (func ls)
  where func = (\(Just x) -> x) . find (elem k)

-- 連結している都市のグループ
renketu :: Int -> [[Int]] -> [[Int]]
renketu 1 _ = [[1]]
renketu n xs = [n : (concat . func) ns] ++ (ns \\ (func ns))
  where func = filter (elemConnected xs n)
        ns = renketu (n-1) xs

-- 都市のグループに連結している都市が含まれているかどうか
elemConnected :: [[Int]] -> Int -> [Int] -> Bool
elemConnected xs n = or . map (beConnected xs n)

-- 連結しているかどうか
beConnected :: [[Int]] -> Int -> Int -> Bool
beConnected xs i j = or [elem [i,j] xs, elem [j,i] xs]

-- 複数行入力
getNLine_ :: Int -> IO [String]
getNLine_ n = replicateM n getLine

-- 文字列を整数に
rInt :: String -> Int
rInt str = read str :: Int