require 'set' N=gets.chomp.to_i setno = Set.new setyes = Set.new is_first = true for num in 1..N ts = gets.chomp.split if ts[4] == 'NO' for i in 0..3 setno.add(ts[i].to_i) end else if is_first setyes = Set.new for i in 0..3 setyes.add(ts[i].to_i) end is_first = false else t = Set.new for i in 0..3 t.add(ts[i].to_i) end setyes = setyes & t end end end if setno.size == 9 puts (Set[0,1,2,3,4,5,6,7,8,9] - setno).to_a else puts (setyes - setno).to_a end