import Control.Monad (replicateM)
import Data.List (transpose)

main = do
    n <- readLn
    if n == 0 then return () else do
        input n >>= return . solve >>= output
        main

input :: Int -> IO ([Int],[Int])
input n = do
    lines <- replicateM n getLine
    let
        [as,bs] = transpose $ map (map read . words) lines
    return (as,bs)

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

solve :: ([Int],[Int]) -> (Int,Int)
solve (as,bs) = solve' as bs 0 0
    where
    solve' [] [] pa pb = (pa,pb)
    solve' (a:as) (b:bs) pa pb
        | a == b = solve' as bs (pa+a) (pb+b)
        | a < b  = solve' as bs pa (pb+a+b)
        | a > b  = solve' as bs (pa+a+b) pb