prev=gets.chomp
puts "Yes"

for i in 1..4999
  now=gets.chomp
  if prev.gsub(/(A)/, prev).eql?(now)
    puts "Yes"
  elsif prev.gsub(/(B)/, prev).eql?(now)
    puts "Yes"
  elsif prev.gsub(/(C)/, prev).eql?(now)
    puts "Yes"
  else
    puts "No"
  end
  prev = now.clone
end