def add word
	@dic[hasF word] << word
end

def hashF word
    temp = word.dup
	temp.gsub!("A", "1")
	temp.gsub!("C", "2")
	temp.gsub!("G", "3")
    temp.gsub!("T", "4")
	return temp.to_i(5) % @dic.length
end

def find word
    @dic[hashF word].each{|v| return true if v == word}
    return false
end

n = gets.to_i
@dic = Array.new(n * 2){[]}
n.times{
	command, word = gets.chomp.split
	case command
	when "insert"
		add word
	else
		puts (find word) ? "yes" : "no"
	end
}