n = gets.to_i
a = [0]
score_a=0
score_b = 0
tmp = [0]
for x in 1..n do
	tmp = gets.chomp.split(" ")
	tmp.map!{|x| x.to_i}
	if tmp[0] > tmp[1]
		score_a += tmp[0] + tmp[1]
	elsif tmp[0] < tmp[1]
		score_b += tmp[0] + tmp[1]
	else
		score_a +=tmp[0]
		score_b +=tmp[1]
	end
end

puts score_a.to_s + " " + score_b.to_s