count = gets.chomp.to_i list = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9] yes_list = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9] count.times do array = gets.split.map(&:to_s) result_array = Array.new if array[4] == "YES" for val in array do yes_list.delete(val.to_i) end for val in yes_list do list.delete(val.to_i) end yes_list = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9] elsif array[4] == "NO" for val in array do list.delete(val.to_i) end end end result = list[0] == 10 ? 0 : list[0] puts result