loop do
  n = gets.to_i
  if n == 0 then break; end

  a = 0
  b = 0

  0..n.times{
    (ap, bp) = gets.split.map(&:to_i)
    if ap > bp then
      a += ap + bp
    elsif ap < bp then
      b += ap + bp
    else
      a += ap
      b += bp
    end
  }

  puts "#{a} #{b}"
end