until (n = gets.chomp.to_i) == 0 ? true:false

  sum_a,sum_b = 0,0 
  n.times do
    nums = gets.split(" ").map{|x| x.to_i}
    if nums[0] == nums[1]
      sum_a += nums[0]
      sum_b += nums[1]
    elsif nums[0] > nums[1]
      sum_a += nums[0] + nums[1]
    else
      sum_b += nums[0] + nums[1]
    end
    nums.clear  
  end
  printf("%d %d\n",sum_a,sum_b)
end