def main
  while (n = gets.to_i) != 0
    sum, diff = 0, 0
    n.times do
      cards = gets.split(" ").map(&:to_i)
      sum += cards[0] + cards[1]
      diff += (cards[0] + cards[1]) * (cards[0] <=> cards[1])
    end
    puts "#{(sum + diff) / 2} #{(sum - diff) / 2}"
  end
end
main