n = gets.to_i

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}"