def add word
	val = hashF word
	@dic[val] << word
end

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

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

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