import Control.Applicative
import Control.Monad
import Control.Monad.State

main = do
    n <- readLn
    if n == 0
       then return ()
       else do
           cards <- map (map read.words)<$>replicateM n getLine :: IO [[Int]]
           putStrLn $ unwords.map show.(\fs -> execState (sequence_ fs) [0,0]) $ map countPoint cards
           main

countPoint :: [Int] -> State [Int] ()
countPoint [a,b]
  | a < b  = get >>= \[suma, sumb] -> put ([suma, sumb+a+b])
  | a == b = get >>= \[suma, sumb] -> put ([suma+a, sumb+b])
  | a > b  = get >>= \[suma, sumb] -> put ([suma+a+b, sumb])