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