while (n = gets.to_i) != 0
  a, b = []*n, []*n
  0.upto(n-1) do |i|
    a[i], b[i] = gets.split(" ").map(&:to_i)
  end
  a_sum, b_sum = 0, 0
  0.upto(n-1) do |i|
    if a[i] > b[i]
      a_sum += a[i] + b[i]
    elsif a[i] < b[i]
      b_sum += a[i] + b[i]
    else
      a_sum += a[i]
      b_sum += b[i]
    end
  end

  puts "#{a_sum} #{b_sum}"
end