def add word
	h1, h2 = getHashV word
	h = h1
	i = 0
	while @dic[h]
		i += 1
		h = (h1 + h2 * i) % @dic.length
	end
	@dic[h] = word
end

def find word
	h1, h2 = getHashV word
	h = h1
	i = 0
	while true
		return true if @dic[h] == word
		return false unless @dic[h]
		i += 1
		h = (h1 + h2 * i) % @dic.length
	end
end

def getHashV word
	num = toN word
	[hashF1(num), hashF2(num)]
end

def hashF1 num
	num % @dic.length
end

def hashF2 num
	num % (@dic.length - 1) + 1
end

def toN word
	num = word.dup
	num.gsub!("A", "1")
	num.gsub!("C", "2")
	num.gsub!("G", "3")
	num.gsub!("T", "4")
	num.to_i
end

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