while true do
  times=gets.chomp.to_i
  if times==0 then
    break
  else
    pointa=0
    pointb=0
    for i in 0...times do
      cards=gets.chomp.split
      
      if cards[0].to_i>cards[1].to_i then
        pointa=pointa+cards[0].to_i+cards[1].to_i
      elsif cards[0].to_i<cards[1].to_i then
        pointb=pointb+cards[0].to_i+cards[1].to_i
      else
        pointa=pointa+cards[0].to_i
        pointb=pointb+cards[1].to_i
      end
    end
    printf("%d %d\n",pointa,pointb)
  end
end