alice = 0
karen = 0

while (num = gets.to_i) != 0
  num.times do
    a, b = gets.split.map(&:to_i)
    if a > b
      alice += (a + b)
    elsif a < b
      karen += (a + b)
    else
      alice += a
      karen += b
    end
  end

  puts alice + " " + karen
end