  1 while (n = readline.chomp!.to_i) != 0
  2   a = b = 0
  3   n.times do
  4     n1, n2 = readline.split(" ").map {|x| x.to_i}
  5     if n1 > n2
  6       a += n1 + n2
  7     elsif n1 == n2
  8       a += n1
  9       b += n2
 10     else
 11       b += n1 + n2
 12     end
 13   end
 14   puts a.to_s + " " + b.to_s
 15 end