a = 0
b = 0

while line = gets
  line = line.chomp.split(" ").map {|num| num.to_i}

  # game start
  if a == 0 && b == 0 && line.length < 2
    next
  end

  # game end
  if line.length < 2
    print a, " ", b, "\n"
    a = 0
    b = 0
    next
  end

  if line[0] > line[1]
    a += line[0] + line[1]
  elsif line[0] < line[1]
    b += line[0] + line[1]
  else
    a += line[0]
    b += line[1]
  end
end