def main
  while (n = gets.to_i) != 0
    p1, p2 = 0, 0
    n.times do
      a, b = gets.split(" ").map(&:to_i)
      if a > b
        p1 += a + b
      elsif a < b
        p2 += a + b
      else
        p1 += a
        p2 += a
      end
    end
    puts "#{p1} #{p2}"
  end
end
main