function makeOpenCards(str) {
    var cards = str.split(' ');
    return {
        A: parseInt(cards[0]),
        B: parseInt(cards[1])
    };
}
var Record = (function () {
    function Record(name) {
        if (typeof name === "undefined") { name = ''; }
        this.getScore = function () {
            var sum = 0;
            this.cards.forEach(function (card, i) {
                sum += card;
            });
            return sum;
        };
        this.name = name;
        this.cards = [];
    }
    return Record;
})();
(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n"), index = 0, n, i, openCard, a, b;
    while(inputs[index] !== '0') {
        n = parseInt(inputs[index++]);
        a = new Record();
        b = new Record();
        for(i = index; i < n + index; i++) {
            openCard = makeOpenCards(inputs[i]);
            if(openCard.A === openCard.B) {
                a.cards.push(openCard.A);
                b.cards.push(openCard.B);
            } else if(openCard.A > openCard.B) {
                a.cards.push(openCard.A);
                a.cards.push(openCard.B);
            } else {
                b.cards.push(openCard.A);
                b.cards.push(openCard.B);
            }
        }
        console.log(a.getScore() + ' ' + b.getScore());
        index += n;
    }
})(require("fs").readFileSync("/dev/stdin", "utf8"));