def main(input = STDIN)
  while (n = input.gets.to_i) != 0
    player, sum = 0, 0
    n.times do
      a, b = input.gets.split(" ").map(&:to_i)
      player += (a + b) * ((a <=> b) + 1) / 2
      sum += a + b
    end
    puts [player, sum - player].join(" ")
  end
end
main