count = gets.chomp.to_i list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] count.times do array = gets.split.map(&:to_s) if array[-1] == "YES" array.each{|arg| list << arg.to_i if arg =~ /^[0-9]+$/} else array.each{|arg| list.delete(arg.to_i) if arg =~ /^[0-9]+$/} end end puts list.uniq.sort{|x,y| list.count(y) <=> list.count(x) }[0]