#!/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

File.open('input.txt') do |f|
  f.each_line do |c|
    if c.to_i == 0
      break
    end

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

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