while true do
  n = gets.to_i
  exit if n == 0
  as = 0
  bs = 0
  for i in 1..n do
    a, b = gets.split.map {|item| item.to_i}
    if a > b then
      as += a + b
    elsif a < b then
      bs += a + b
    else
      as += a
      bs += b
    end
  end
  puts as.to_s + " " + bs.to_s
end