# initialize scores
score_a = 0
score_b = 0

# get n
loop do
  n = gets.to_i

  # compare cards and add score
  n.times do
    card_a, card_b = gets.split(" ").map(&:to_i)
    if card_a > card_b
      score_a += card_a + card_b
    elsif card_a < card_b
      score_b += card_a + card_b
    else
      score_a += card_a
      score_b += card_b
    end
  end

  if n == 0
    puts "#{score_a} #{score_b}"
    break
  end
end