import Control.Monad
import Data.Array
import Data.Graph
import Data.List

main = sub =<< get

sub [n,k,l] = sol n <$> replicateM k get <*> replicateM l get >>= put

get = fmap read . words <$> getLine

put = putStrLn . unwords . fmap show

sol n rds rws = f <$> [1..n]
  where
  grd = buildUndirectedG n rds
  grw = buildUndirectedG n rws
  f v = length $ (reachable grd v) `intersect` (reachable grw v)

-- build a undirected graph from edges
buildUndirectedG m es = buildG (bounds g) (edges g ++ (edges . transposeG) g)
  where
  g = buildG (1,m) $ fmap (\[u,v] -> (u,v)) es