#include <stdio.h>

#define N 1000000

int num[N][12];
int cnt;

void insert(char *str) {
	int i=0;

	while (str[i] != '\0') {
		if (str[i] == 'A') {
			num[cnt][i] = 1;
		} else if (str[i] == 'C') {
			num[cnt][i] = 2;
		} else if (str[i] == 'G') {
			num[cnt][i] = 3;
		} else {
			num[cnt][i] = 4;
		}
		i++;
	}
	cnt++;
}

int find (char *str) {
	int i,j=0;
	for (i=0;i<=cnt;i++) {
		while (str[j] != '\0') {
			if (str[i] == 'A' && num[i][j] != 1) {
				return 1;
			}
			if (str[i] == 'C' && num[i][j] != 2) {
				return 1;
			}
			if (str[i] == 'G' && num[i][j] != 3) {
				return 1;
			}
			if (str[i] == 'T' && num[i][j] != 4) {
				return 1;
			}
			j++;
		}
		if (str[j] == '\0' && num[i][j] == 0) return 0;
	}
	return 0;
}

int main() {
	int i, n;
	char com[8];
	char str[13];

	scanf("%d", &n);

	for (i=0;i<n;i++) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%s", str);
			insert(str);
		} else if (com[0] == 'f') {
			scanf("%s", str);
			if (find(str) == 0) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

	return 0;
}