while (n = gets.chomp.to_i) != 0
  pa,pb = [0, 0]
  n.times do
    a,b = gets.chomp.split.map(&:to_i)
    if a > b
      pa += a + b
    elsif a == b
      pa += a
      pb += b
    elsif a < b
      pb += a + b
    end
  end
  puts "#{pa} #{pb}"
end