import Control.Monad

main :: IO ()
main = do
  ra <- getLine
  if ra == "0 0"
    then return ()
    else do
      putStrLn $ solve ra
      main

solve :: String -> String
solve rs = toStr (check (words rs))
  where
    toStr :: (Int,Int) -> String
    toStr (a,b) = (show a) ++ " " ++ (show b)
    
    check :: [String] -> (Int,Int)
    check [r,a] = check' [r,a] r (0,0)
      where
        check' :: [String] -> String -> (Int,Int) -> (Int,Int)
        check' _ [] (a,b) = (a,b)
        check' [xs, (y:ys)] (z:zs) (a,b)
          | y == z = check' [xs,ys] zs (a+1,b)
          | elem y xs = check' [xs,ys] zs (a,b+1)
          | otherwise = check' [xs,ys] zs (a,b)