answer = Array.new
while (num = $stdin.gets.to_i) > 0
	a = 0
	b = 0
	1.upto( num ){
		cards = $stdin.gets.split( /\s/ )
		n1 = cards[ 0 ].to_i
		n2 = cards[ 1 ].to_i

		a += ( n1 + n2 ) if n1 > n2
		b += ( n1 + n2 ) if n1 < n2
		if n1 == n2
			a += n1 
			b += n2 
		end

		#a += n1; b += n2 if n1 == n2
	}
	answer << [a,b]
end

answer.each{ |ans|
	printf( "%d %d\n", ans[ 0 ], ans[ 1 ] )
}
