let read_lines n =
  let rec read_lines n acc =
    if n = 0 then List.rev acc
    else read_lines (pred n) ((read_line ()) :: acc) in
  read_lines n []

let score data_set =
  let scores = List.map
                 (fun (a, b) ->
                  let s = a + b in
                  if a > b then (s, 0)
                  else if a < b then (0, s)
                  else (a, b))
                 data_set in
  List.fold_left
    (fun (a_acc, b_acc) (a, b) -> (a_acc + a, b_acc + b))
    (0, 0)
    scores

let rec solve () =
  let n = int_of_string @@ read_line () in
  if n = 0 then ()
  else
    let data_set = List.map
                     (fun line -> Scanf.sscanf line "%d %d" (fun a b -> (a, b)))
                     (read_lines n) in
    let a, b = score data_set in
    Printf.printf "%d %d\n" a b;
    solve ()

let () = solve ()