ary = Array.new(10) N = gets.to_i N.times do tmp = gets.split nums = tmp[0..-2].map(&:to_i) answer = tmp[-1] if answer == 'YES' ary.each_with_index do |status, idx| if nums.index(idx) ary[idx] ||= true else ary[idx] = false end end else nums.each{ |num| ary[num] = false } end end puts (ary.index(true) || ary.index(nil))