table = [*0..9] N = gets.to_i N.times do tmp = gets.split tmp[4] == 'YES' ? table &= tmp[0..3].map(&:to_i) : table -= tmp[0..3].map(&:to_i) end p table[0]