n=gets.to_i a=(0..9).to_a n.times{|i| u=gets.split v=u[0..-2].map(&:to_i) if u[-1]=="NO" a=a-v else a=v&a end if a.size==1 puts a exit end }