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

$LOAD_PATH << File.dirname(__FILE__)

n = gets().to_i

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

puts "#{a_score} #{b_score}"