#include <stdio.h>
#include <math.h>
main(){
  int i,j,n,code;
  char cm[7],o,dict[262145];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",cm);
    j=0; code=0;
    while(j<=8){
      scanf("%c",&o);
      if(o=='\n') break;
      else if(o=='A') code+=1*pow(4,j);
      else if(o=='C') code+=2*pow(4,j);
      else if(o=='G') code+=3*pow(4,j);
      else if(o=='T') code+=4*pow(4,j);
      else j--;
      j++;
    }
    if(cm[0]=='i')
      dict[code]=1;
    if(cm[0]=='f')
      dict[code]?printf("yes\n"):printf("no\n");
  }
  return 0;
}