#include<stdio.h>
#include<stdlib.h>
#include<string.h>


typedef struct wordcard{
 int num;
 struct wordcard *next;
}word;


int henkan(char str[]){
int i=0;

while(str[i]!='\0'){
 switch(str[i]){
  case 'A':str[i]='1';
           break;
  case 'C':str[i]='2';
           break;
  case 'G':str[i]='3';
           break;
  case 'T':str[i]='4';
           break;
 }
 i++;
}

return atoi(str);
}


int main(){
int n,i;
word* A[13];
word* C[13];
word* G[13];
word* T[13];
char com[3];
word *new;
int x;
word **p;
char temp[13];
word *q;
char y;
int z;

for(i=1;i<=12;i++){
 A[i]=NULL;
 C[i]=NULL;
 G[i]=NULL;
 T[i]=NULL;
}



scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%s",com);

 switch(com[0]){
  case 'i':new=(word*)malloc(sizeof(word));
           scanf("%s",temp);
           x=strlen(temp);
           y=temp[0];
           new->num=henkan(temp);
           new->next=NULL;
           switch(y){

             case 'A':p=&A[x];
                      while((*p)!=NULL){
                         if(((*p)->num) < (new->num)){p=&((*p)->next);}
                         else{break;}
                      }
                      if((*p)==NULL){(*p)=new;}
                      else{new->next=(*p);
                           (*p)=new;}
                      break;
             case 'C':p=&C[x];
                      while((*p)!=NULL){
                         if((*p)->num < new->num)p=&((*p)->next);
                         else{break;}
                      }
                      if((*p)==NULL){(*p)=new;}
                      else{new->next=(*p);
                           (*p)=new;}
                      break;
             case 'G':p=&G[x];
                      while((*p)!=NULL){
                         if((*p)->num < new->num)p=&((*p)->next);
                         else{break;}
                      }
                      if((*p)==NULL){(*p)=new;}
                      else{new->next=(*p);
                           (*p)=new;}
                      break;
             case 'T':p=&T[x];
                      while((*p)!=NULL){
                         if((*p)->num < new->num)p=&((*p)->next);
                         else{break;}
                      }
                      if((*p)==NULL){(*p)=new;}
                      else{new->next=(*p);
                           (*p)=new;}
                      break;
            }

           break;
  case 'f':scanf("%s",temp);
           x=strlen(temp);
           y=temp[0];
           z=henkan(temp);
           switch(y){
           
             case 'A':q=A[x];
                      while(q!=NULL){
                        if(z > (q->num))q=q->next;
                        else{break;}
                      }
                      if(q==NULL)printf("no\n");
                      else{if(z==(q->num))printf("yes\n");}
                      break;

             case 'C':q=C[x];
                      while(q!=NULL){
                        if(z > q->num)q=q->next;
                        else{break;}
                      }
                      if(q==NULL)printf("no\n");
                      else{if(z==(q->num))printf("yes\n");}
                      break;

             case 'G':q=G[x];
                      while(q!=NULL){
                        if(z > q->num)q=q->next;
                        else{break;}
                      }
                      if(q==NULL)printf("no\n");
                      else{if(z==(q->num))printf("yes\n");}
                      break;

             case 'T':q=T[x];
                      while(q!=NULL){
                        if(z > q->num)q=q->next;
                        else{break;}
                      }
                      if(q==NULL)printf("no\n");
                      else{if(z==(q->num))printf("yes\n");}
                      break;
            }

           break;
 }/*switch end*/

}/*for end*/


return 0;
}
