while n = gets.to_i do
  if n == 0 then
    break
  end
  
  a,b = 0,0

  n.times do
    data = gets.split().map(&:to_i)
    if data[0] > data[1] then
      a += data[0] + data[1]
    elsif data[0] < data[1] then
      b += data[0] + data[1]
    else
      a += data[0]
      b += data[1]
    end
  end
  
  puts "#{a} #{b}"
end