while true
    n = gets.to_i
    break if n == 0
    score = [0, 0]
    n.times{
        a, b = gets.chomp.split.map(&:to_i)
        if a == b
            score[0] += a
            score[1] += b
        elsif a > b
            score[0] += (a + b)
        else
            score[1] += (a + b)
        end
    }
    puts score.join(" ")
end
