class NumbersGame
    attr_reader :n, :gamedata

    def initialize(n: 0, gamedata: [])
        @n, @gamedata = n, gamedata
    end

    def cause
        begin
            @n = Integer(gets.chomp)
            @gamedata = @n.times.map { gets.chomp.split }
        rescue
            
        end
    end

    def numerization
        ans = (0..9).to_a
        @gamedata.each do |lst|
            num = lst[0..3].map { |v| Integer(v) }
            if lst[4] == "YES"
                ans &= num
            else
                ans -= num
            end
        end
        ans
    end

    def result
        puts numerization
    end

    def run
        cause
        result
    end
end

if $0 == __FILE__
    NumbersGame.new.run
end