while (n=gets.to_i)!=0
    p1 = 0
    p2 = 0
    for i in 0...n
        a,b = gets.split(" ").map(){|num|num.to_i}
        if a<b
            p2 += a+b
        elsif a>b
            p1 += a+b
        else
            p1 += a
            p2 += b
        end
    end
    puts(sprintf("%d %d",p1,p2))
end