loop do
	n = STDIN.gets.to_i
	break if n.zero?

	a_score = 0
	b_score = 0
	n.times do
		a, b = STDIN.gets.split.map(&:to_i)
		case a <=> b
		when 1
			a_score += a + b
		when 0
			a_score += a
			b_score += a
		else
			b_score += a + b
		end
	end

	puts "#{a_score} #{b_score}"
end