import Control.Applicative
import Control.Monad

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.foldl countPoint [0,0] $ cards
           main

countPoint :: [Int] -> [Int] -> [Int]
countPoint [a,b] [a1,b1]
  | a1 > b1 = [a + a1+b1, b]
  | a1 < b1 = [a, b + a1+b1]
  | a1 == b1 = [a+a1, b+b1]