while true
  n = gets.chomp.to_i
  break if n == 0
  sum_x, sum_y = 0, 0
  n.times do |i|
    x, y = gets.chomp.split(" ").map(&:to_i)
    sum_x, sum_y = x > y ? [sum_x + x + y, sum_y] : y > x ? [sum_x, sum_y + x + y] : [sum_x + x, sum_y + y]
  end
  puts "#{sum_x} #{sum_y}"
end