until (n = gets.to_i) == 0 do

    ascore = 0
    bscore = 0
    
    for i in 1..n do
        acard, bcard = gets.split(" ").map(&:to_i)
        
        if acard > bcard then
            ascore += acard + bcard
        elsif bcard > acard then
            bscore += acard + bcard
        else
            ascore += acard
            bscore += bcard
        end
    end
    
    printf("#{ascore} #{bscore}\n")

end