#!/usr/bin/ruby

def result(cardLists)
  aScore, bScore = 0, 0
  cardLists.each do |aCards, bCards|
    if aCards < bCards
      bScore += aCards + bCards
    elsif aCards == bCards
      aScore += aCards
      bScore += aCards
    else
      aScore += aCards + bCards
    end
  end
  [aScore, bScore]
end

while true
  c = STDIN.gets
  if c.to_i == 0
    break
  end

  cardLists=[]
  (1..c.to_i).each do
    cardLists << STDIN.gets.split(/\s*/).map(&:to_i)
  end

  puts result(cardLists).join(" ")
end