while (n = readline.chomp!.to_i) != 0
  a = b = 0 
  n.times do
    n1, n2 = readline.split(" ").map {|x| x.to_i}
    if n1 > n2
      a += n1 + n2
    elsif n1 == n2
      a += n1
      b += n2
    else
      b += n1 + n2
    end 
  end 
  puts a.to_s + " " + b.to_s
end