import Control.Applicative
import Control.Monad
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as BC
import Data.ByteString.Char8 (ByteString)
import Data.List

main = do
    n <- readLn
    unless (n==0) $ do
        cards <- map parseLine <$> replicateM n BC.getLine
        report $ score cards
        main

parseLine :: ByteString -> (Int, Int)
parseLine l = case map (fst . fromJust . BC.readInt) . BC.words $ l of
                 [a,b] -> (a,b)

report :: (Int, Int) -> IO ()
report (a,b) = putStrLn . unwords . map show $ [a,b]

score :: [(Int, Int)] -> (Int, Int)
score = foldl' f (0, 0)
    where
        f (scoreA, scoreB) (a,b) =
            case a `compare` b of
                 GT -> (a+b+scoreA, scoreB)
                 LT -> (scoreA, a+b+scoreB)
                 EQ -> (a+scoreA, b+scoreB)