loop do
sum = {:a=>0,:b=>0}
    n = gets.to_i
    if n == 0
        break
    end
    n.times do
        a,b = gets.split(' ').map(&:to_i)
        if a>b
            sum[:a] += a+b
        else
            sum[:b] += a+b
        end
    end
    print "#{sum[:a]} #{sum[:b]}\n"
end