a = [*0..9] gets.to_i.times do l = gets.split(" ") _l = l[0..-2].map(&:to_i) if(l[-1] == "YES") a &= _l else a -= _l end end puts a[0]