loop do
  count = gets.to_i
  break if count == 0

  pa = 0
  pb = 0
  
  count.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
  
    if a > b
      pa += a + b
    elsif a < b
      pb += a + b
    else
      pa += a
      pb += b
    end
  end
  
  puts "#{pa} #{pb}"
end