# ruby -Ks
n=0
roop=0
a=[]
b=[]
a_total=[]
b_total=[]
c=[]
d=[]
while true
	n=gets.to_i
	n.times do |i|
		a[i],b[i]=gets.chomp.split.map(&:to_i)
		total=a[i]+b[i]
		if a[i]>b[i]
			a_total<<total
		elsif b[i]>a[i]
			b_total<<total
		else
			a_total<<a[i]
			b_total<<b[i]
		end
		total=0
	end
	c<<a_total.inject(&:+)
	d<<b_total.inject(&:+)
end

c.length.times do |i|
	p "#{c[i]} #{d[i]}\n"
end