loop {
  suma = 0
  sumb = 0

  num = gets.to_i

  if num == 0
    break;
  end

  (1..num).each {
    a, b = gets.split(" ").map { |num|
      num.to_i
    }
    if a > b
      suma += a + b
    elsif a < b
      sumb += a + b
    else 
      suma += a
      sumb += b
    end
  }

  printf("%d %d\n",suma, sumb)

}