import qualified Data.ByteString.Char8 as BS
import Data.Array.IO
import Control.Monad
import Control.Applicative
import Data.Maybe
import qualified Data.Map as Map
import Data.List
import Data.Maybe

type UnionFindIO = IOArray Int (Int,Int)
 
newUFIO :: Int -> IO UnionFindIO
newUFIO n = newListArray (1,n) (zip [1..n] (repeat 1))
 
findUFIO :: UnionFindIO -> Int -> IO Int
findUFIO uf x = do
  (parent,size) <- readArray uf x
  if parent == x then
    return x
    else do
    next <- findUFIO uf parent
    writeArray uf x (next,size)
    return next
 
sameUFIO :: UnionFindIO -> Int -> Int -> IO Bool
sameUFIO uf x y = do
  xx <- findUFIO uf x
  yy <- findUFIO uf y
  return $ xx == yy
 
uniteUFIO :: UnionFindIO -> Int -> Int -> IO ()
uniteUFIO uf x y = do
  xx <- findUFIO uf x
  yy <- findUFIO uf y
  (_,xs) <- readArray uf xx
  (_,ys) <- readArray uf yy

  if xx == yy then
    return ()
    else if xs < ys then do
    writeArray uf xx (yy,0)
    else if xs > ys then do
    writeArray uf yy (xx,0)
    else do
    writeArray uf yy (xx,0)
    writeArray uf xx (xx,xs+1)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
readIntBS = fst . fromJust . BS.readInt

main = do
  (n,k,l) <- listToTuple3 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int,Int)

  uf1 <- newUFIO n
  replicateM k $ do
    (p,q) <- listToTuple2 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int)
    uniteUFIO uf1 p q

  list1 <- forM [1..n] $ \i -> do
    findUFIO uf1 i

  
  uf2 <- newUFIO n
  replicateM l $ do
    (r,s) <- listToTuple2 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int)
    uniteUFIO uf2 r s

  list2 <- forM [1..n] $ \i -> do
    findUFIO uf2 i

  let
    pairs = zip list1 list2
    dict = Map.fromList . map (\xs -> (head xs, length xs)) . group . sort $ pairs

  putStrLn $ unwords . map show . catMaybes $ map (\p -> Map.lookup p dict) pairs
