battle = gets.to_i

point=[0,0]

battle.times do
	card=gets.split(" ").map{|x| x.to_i}
	if card[0] > card[1]
		point[0] += card.inject{|sum,n| sum + n}
	elsif card[0] < card[1]
		point[1] += card.inject{|sum,n| sum + n}
	elsif card[0] == card[1]
		point[0] += card[0]
		point[1] += card[1]
	end
end

print point[0]," ",point[1]
