result1 = Array.new
result2 = Array.new
n=1
while true
	n = gets.to_i
	if n==0
	break
	end	
	score1=0
	score2=0
	n.times do
num1,num2 = gets.split.map(&:to_i)
if num1>num2
	score1 += num1+num2
elsif num1<num2
	score2+= num1+num2
else
	score1 += num1
	score2 += num2
end
end
result1.push(score1)
result2.push(score2)
end

while !result1.empty?
puts "#{result1.shift} #{result2.shift}"
end