let split_int s =
  let l = Str.split (Str.regexp_string " ") s
          |> List.map int_of_string |> List.nth
  in
  (l 0, l 1)
;;

let rec read () =
  let n = read_int () in
  if n > 0 then
    let rec loop a b= function
        0 -> (a, b)
      | i ->
         let (x,y) = read_line () |> split_int in
         if x > y then loop (a+x+y) b (i-1)
         else if x < y then loop a (b+x+y) (i-1)
         else loop (a+x) (b+y) (i-1)
    in
    let (a, b) = loop 0 0 n
    in
    Printf.printf "%d %d\n" a b;read ()
;;

let () = read ();;