str = STDIN.gets
num = str.chomp.to_i
ans = []
while (num != 0)
	a = 0
	b = 0
	for i in 1..num do
		str = STDIN.gets
		cards = str.split(" ")
		card_a = cards[0].to_i
		card_b = cards[1].to_i
		
		if card_a == card_b then
			a += card_a
			b += card_b
		elsif card_a > card_b then
			a += card_a + card_b
		else
			b += card_a + card_b
		end
	end
	ansstr = a.to_s + " " + b.to_s
	ans.push(ansstr)
	str = STDIN.gets
	num = str.chomp.to_i
end

for out in ans do
	print out ,"\n"
end