n = 1
j = 0
arry = []
a = []
b = []
a_sum = []
b_sum = []
while n != 0
	n = gets.to_i
	a_sum[j] = 0
	b_sum[j] = 0
	n.times do |i|
		arry = gets.split{" "}
		a[i] = arry[0].to_i
		b[i] = arry[1].to_i
		if a[i] > b[i]
			a_sum[j] += (a[i] + b[i])
		elsif b[i] > a[i]
			b_sum[j] += (a[i] + b[i])
		else
			a_sum[j] += a[i]
			b_sum[j] += b[i]
		end
	end
	j += 1
end
(j - 1).times do |k|
	printf "#{a_sum[k]} #{b_sum[k]}\n"
end