while n = gets
  n = n.to_i
 
  break if n == 0
  
  a_score = 0
  b_score = 0
  
  n.times do
  	
  	a, b = gets.split.map(&:to_i)
  	
  	if a == b 
  	  a_score += a
  	  b_score += b
  	elsif a > b
  	  a_score += a + b
    else
      b_score += a + b
    end
  end
  
  puts "#{a_score} #{b_score}"
  
end