# Original solution
n = int(input())
a_dict = [[],[],[],[],[]]
c_dict = [[],[],[],[],[]]
t_dict = [[],[],[],[],[]]
g_dict = [[],[],[],[],[]]

for i in range(n):
	cmd = input().split()
	char = cmd[1]
	
	if cmd[0] == "insert":
		if char[0] == "A":
			if len(char) == 1:
				a_dict[0].append(char)
			elif char[1] == "A":
				a_dict[1].append(char)
			elif char[1] == "T":
				a_dict[2].append(char)
			elif char[1] == "C":
				a_dict[3].append(char)
			else:
				a_dict[4].append(char)
		elif char[0] == "T":
			if len(char) == 1:
				t_dict[0].append(char)
			elif char[1] == "A":
				t_dict[1].append(char)
			elif char[1] == "T":
				t_dict[2].append(char)
			elif char[1] == "C":
				t_dict[3].append(char)
			else:
				t_dict[4].append(char)
		elif char[0] == "C":
			if len(char) == 1:
				c_dict[0].append(char)
			elif char[1] == "A":
				c_dict[1].append(char)
			elif char[1] == "T":
				c_dict[2].append(char)
			elif char[1] == "C":
				c_dict[3].append(char)
			else:
				c_dict[4].append(char)
		else:
			if len(char) == 1:
				g_dict[0].append(char)
			elif char[1] == "A":
				g_dict[1].append(char)
			elif char[1] == "T":
				g_dict[2].append(char)
			elif char[1] == "C":
				g_dict[3].append(char)
			else:
				g_dict[4].append(char)
	else:
		if char[0] == "A":
			if len(char) == 1:
				if char in a_dict[0]:
					print("yes")
				else:
					print("no")
			elif char[1] == "A":
				if char in a_dict[1]:
					print("yes")
				else:
					print("no")
			elif char[1] == "T":
				if char in a_dict[2]:
					print("yes")
				else:
					print("no")
			elif char[1] == "C":
				if char in a_dict[3]:
					print("yes")
				else:
					print("no")
			else:
				if char in a_dict[4]:
					print("yes")
				else:
					print("no")
		elif char[0] == "T":
			if len(char) == 1:
				if char in t_dict[0]:
					print("yes")
				else:
					print("no")
			elif char[1] == "A":
				if char in t_dict[1]:
					print("yes")
				else:
					print("no")
			elif char[1] == "T":
				if char in t_dict[2]:
					print("yes")
				else:
					print("no")
			elif char[1] == "C":
				if char in t_dict[3]:
					print("yes")
				else:
					print("no")
			else:
				if char in t_dict[4]:
					print("yes")
				else:
					print("no")
		elif char[0] == "C":
			if len(char) == 1:
				if char in c_dict[0]:
					print("yes")
				else:
					print("no")
			elif char[1] == "A":
				if char in c_dict[1]:
					print("yes")
				else:
					print("no")
			elif char[1] == "T":
				if char in c_dict[2]:
					print("yes")
				else:
					print("no")
			elif char[1] == "C":
				if char in c_dict[3]:
					print("yes")
				else:
					print("no")
			else:
				if char in c_dict[4]:
					print("yes")
				else:
					print("no")
		else:
			if len(char) == 1:
				if char in g_dict[0]:
					print("yes")
				else:
					print("no")
			elif char[1] == "A":
				if char in g_dict[1]:
					print("yes")
				else:
					print("no")
			elif char[1] == "T":
				if char in g_dict[2]:
					print("yes")
				else:
					print("no")
			elif char[1] == "C":
				if char in g_dict[3]:
					print("yes")
				else:
					print("no")
			else:
				if char in g_dict[4]:
					print("yes")
				else:
					print("no")

	

# Optimized solution
n = int(input())
dic = {}

for i in range(n):
	line = input().split()
	cmd = line[0]
	ope = line[1]
	if cmd == "insert":
		dic[ope] = 1
	else:
		try:
			dic[ope] == 1
		except:
			print("no")
		else:
			print("yes")