# -*- coding: utf-8 -*-

$output = []

def main
    n = gets().to_i
    return false if n==0

    a_cards = []
    b_cards = []
    n.times do |i|
        str = gets().split(/\s+/)
        a_cards << str[0].to_i
        b_cards << str[1].to_i
    end

    # ゲーム
    a_score = 0
    b_score = 0
    n.times do |i|
        if a_cards[i] > b_cards[i] # aの勝ち
            a_score += (a_cards[i] + b_cards[i])
        elsif a_cards[i] == b_cards[i] # 引き分け
            a_score += a_cards[i]
            b_score += b_cards[i]
        else # bの勝ち
            b_score += (a_cards[i] + b_cards[i])
        end
    end

    $output << "#{a_score} #{b_score}"
    return true
end

while(main)
end

$output.each do |str|
    puts str
end