import Text.Printf

turn:: (Int,Int) -> (Int,Int)
turn (a,b)
    | a >  b = (a+b,0)
    | a == b = (a,b)
    | a <  b = (0,a+b)
	
acm:: [(Int,Int)] -> (Int,Int)
acm [] = (0,0)
acm ((a,b):xs) =
	let (c,d) = acm xs
	in
		(a+c,b+d)

main = do
    c <- getContents
    let t0= map words $ drop 1 $ lines c
        t1= map (map read) t0 :: [[Int]]
        i = map (\(x0:x1:xs) -> (x0,x1)) t1
        o = acm $ map turn i
		
    printf "%d %d\n" (fst o) (snd o)