if __FILE__ == $0
  currentCup = "A"
  while line = gets
    x, y = line.rstrip.split(',')
    if currentCup == x
      currentCup = y
    elsif currentCup == y
      currentCup = x
    end
  end
  puts currentCup
end