#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 999769

int hantei(char c){
  if(c == 'A')return 1;
  else if(c == 'C')return 2;
  else if(c == 'G')return 3;
  else if(c == 'T')return 4;
  else return 0;
}

int main(){
  int i,j,k,n,sum,h,p=1;
  int h1,h2;
  char command[7],str[1000000][13],key[13];
  for(i=0;i<M;i++)str[i][0]='\0';
  scanf("%d",&n);
  if(n>1000000) exit(2);
  for(i=0;i<n;i++){
    sum=0;
    p=1;
    scanf("%s %s",command,key);
    for(j=0;j<strlen(key);j++){
      sum+=p*(hantei(key[j]));
      p *= 5;
    }
    
    if(command[0] == 'i'){
      for(k=0;;k++){
	h1=sum%M;
	h2=1+(sum%(M-1));
	h=(h1+k*h2)%M;
	if(strcmp(str[h],key) == 0)break;
	else if(strlen(str[h]) == 0){
	  strcpy(str[h],key);
	  break;
	}
      }
    }else{
      for(k=0;;k++){
	h1=sum%M;
	h2=1+(sum%(M-1));
	h=(h1+k*h2)%M;
	if(strcmp(str[h],key) == 0){
	  printf("yes\n");
	  break;
	}
	else if(strlen(str[h]) == 0){
	  printf("no\n");
	  break;
	}
      }
    }
  } 
  return 0;
}



