while 0 < n = gets.chomp.to_i
  a_total=0
  b_total=0
  n.times do 
    a, b = gets.chomp.split(' ').map(&:to_i)
    if a < b
      b_total += a + b
    elsif a > b
      a_total += a + b
    else
      a_total += a
      b_total += b
    end
  end
  puts "#{a_total} #{b_total}"
end