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

int N=64;



int hantei(char *x){
  int check=0;
  int i;
  for(i=0;i<3;i++){
    if(x[i]=='A') check+=3*pow(4,i);
    else if(x[i]=='G') check+=2*pow(4,i);
    else if(x[i]=='C') check+=pow(4,i);
  }
  return check;
}



int main(){
  int n;
  char inst[8];
  char x[13];
  char ***dic;
  int dicsize[256]={};
  char **dic2;
  int i,j;
  int size=0;
  
  dic=malloc(N*sizeof(char **));
  scanf("%d",&n);
  for(i=0;i<N;i++) dic[i]=malloc(n*sizeof(char *));
  for(i=0;i<N;i++){
    for(j=0;j<n;j++){
      dic[i][j]=malloc(11*sizeof(char));
    }
  }
  dic2=malloc(n*sizeof(char *));
  for(i=0;i<n;i++) dic2[i]=malloc(13*sizeof(char));

  int basyo;
  
  for(i=0;i<n;i++){
    scanf("%*[\n ]%s",inst);
    if(inst[0]=='i'){
      scanf("%*[ ]%s",x);
      if(strlen(x) <3){ 
        strcpy(dic2[size],x);
        size+=1;
      }
      else{
        basyo=hantei(x);
        strcpy(dic[basyo][dicsize[basyo]],&x[2]);
        dicsize[basyo]+=1;
      }
    }
    else if(inst[0]=='f'){
      scanf("%*[ ]%s",x);
      if(strlen(x) <3){
        for(j=0;j<size;j++){
          if(strcmp(x,dic2[j])==0){
            printf("yes\n");
            break;
          }
        }
        if(j==size) printf("no\n");
      }
      else{
        basyo=hantei(x);
        for(j=0;j<dicsize[basyo];j++){
          if(strcmp(&x[2],dic[basyo][j])==0){
            printf("yes\n");
            break;
          }
        }
        if(j==dicsize[basyo]) printf("no\n");
       }  
    }
  }
  return 0;
}
