
a1 = Array.new
a2 = Array.new 
loop do
score1 =0
score2 =0

n = gets.to_i
if n == 0
	break
end
n.times do
	num1,num2 = gets.split.map(&:to_i)
	if num1>num2
		score1 += num1+num2
	elsif num2>num1
		score2 += num1+num2
	else
		score1 += num1
		score2 += num2
	end
end
a1.push(score1)
a2.push(score2)
end
while !a1.empty?
puts "#{a1.shift} #{a2.shift}"
end