#encoding:utf-8 No.0500 2014.11.10
while true
  num_of_cards = gets.chomp.to_i
  if num_of_cards == 0
    break
  end

  score_A = 0
  score_B = 0
  num_of_cards.times do
    a,b = gets.chomp.split.map{|n| n.to_i}
    if a > b
      score_A += a+b
    elsif a < b
      score_B += a+b
    else
      score_A += a ; score_B += b
    end
  end

  print "#{score_A} #{score_B}\n"
end