import Data.Graph

main = interact $ put . sub . get

get = fmap (fmap read . words) . lines

put = unwords . fmap show

sub ([n,m,k]:as) = sol n (ps $ take m as) (ps $ drop m as)

ps [] = []
ps ([a,b]:abs) = (a,b):(b,a):ps abs

sol n es bs = length . f <$> vertices g
  where
  g = buildG (1,n) es
  f i = [(i,j) | j <- reachable g i, i/=j, (i,j) `notElem` es, (i,j) `notElem` bs]