#include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<cwctype>
#include<algorithm>
#include<math.h>

using namespace std;

bool data[5][5][5][5][5][5][5][5][5][5][5][5]={false};

void insert(string str){
	int count[12]={0};
	for(int i=0;i<str.size();i++){
		switch(str.at(i)){
		case 'A':count[i]=1;break;
		case 'T':count[i]=2;break;
		case 'C':count[i]=3;break;
		case 'G':count[i]=3;break;
		}
	
	
	}
	data[count[0]][count[1]][count[2]][count[3]][count[4]][count[5]][count[6]][count[7]][count[8]][count[9]][count[10]][count[11]]=true;
}

bool find(string str){
	int count[12]={0};
	for(int i=0;i<str.size();i++){
		switch(str.at(i)){
		case 'A':count[i]=1;break;
		case 'T':count[i]=2;break;
		case 'C':count[i]=3;break;
		case 'G':count[i]=3;break;
		}
	
	
	}
	return data[count[0]][count[1]][count[2]][count[3]][count[4]][count[5]][count[6]][count[7]][count[8]][count[9]][count[10]][count[11]];

}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string c,m;
		cin>>c>>m;
		if(c=="insert"){
		insert(m);
		}
		else{
			if(find(m))cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}

	}
	return 0;
}