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