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

int h1(int ,int);
int h2(int , int);
main()
{

              /*???????????????
???????????????????????\?????????????????????????????????
???????????\?????´??????????????????????????????????§????????????????????????¨?????§?????????
??????????????´??°??????????????????????????\??¢??°??????????????????????????\???????????????????´??????????
collusion??????????????´??????????????????????????\??¢??°????????????

????????????????????????????????§???????????§????????????????????´??°??????????¶????????????????
?????????????????§??????????????????????????????????????????
???????????\???????????????insert?????°????????¨??????

*/

  int num,*kazu,*table,*soe;
  char **moji,**command;
  int length=0,count,corre=0,i,j,s,d,k;

  scanf("%d",&num);
  

  moji = malloc(sizeof(char)*num);
  command = malloc(sizeof(char)*num);
  kazu = malloc(sizeof(int)*num);
  soe = malloc(sizeof(int)*num);
  table = malloc(sizeof(int)*(num));
  for(i=0;i<num;i++)
    {
      moji[i] = malloc(sizeof(char)*12);/*12??????????????????????????¨???*/
      command[i] = malloc(sizeof(char)*7);/*find??¨insert??????????????????*/
     
    }


  for(s=0;s<num;s++)
    {
      /* printf("YO!\n");*/
      scanf("%s %s",command[s],moji[s]);/*??´??°??????????????????*/
      length = strlen(moji[s]);/*???????????????????????¬???*/
      kazu[s] = 0;
      /* printf("%s\n",moji[s]);
	 printf("%d\n",length);*/
      for(j=0;j<length;j++)/*????????§atoi????????????????????????????????´??°?????§?????????????????????*/
	
        {
	  if(moji[s][j] == 'A')
	    {
	      kazu[s] += 65;
	    }
	  else if (moji[s][j] == 'G')
	    {
	      kazu[s] += 71;
	    }
	  else if(moji[s][j] == 'C')
	    {
	      kazu[s] += 67;
	    }
	  else/*T?????´???*/
	    {
	      kazu[s] += 84;
	    }
	  
        }
      /* printf("%d\n",kazu[s]);???????????§?¢??????????*/

          if(strcmp(command[s],"insert")==0)/*???????????????????????????????????\???????????????num????????????*/
            {
	      /* printf("ok\n");*/
      
      
                  d  = kazu[s]%num;
                  
                  
                  while(1)
                    {
                      count = 0;
		      k = 1;
		      /* printf("break????????£?????????\n");*/
                      for(j=0;j<num;j++)
                        {
                          
                          if(soe[j] == d)
                            {
                              d = (h1(kazu[s],num) + k*h2(kazu[s],num))%num;/*????????§??¬?????????*/
                              count++;
			      k++;
                            }
                          
                        }
                      /*count????????????????????°*/
                      if(count==0)break;
                      
                    }/*while?????¨???*/
                  
                  soe[s] = d;
                  table[soe[s]] = kazu[s];
		  /* printf("soe is %d\n",soe[s]);
		     printf("%d\n",table[soe[s]]);*/
                  
	     
              /*????????§???????????\?????????????????´??°??\???*/
              
            }/*strcmp???if??¨???*/


	  else if(strcmp(command[s],"find")==0)
	   {
	     /* printf("ok2\n");*/
	    corre = 0;
	    for(i=0;i<num;i++)
	      {
		if(table[i] == kazu[s]){
		  printf("yes\n");
		  corre++;
		}		
	      }
	    if(corre==0)printf("no\n");
	  }
    }/*?????¨???????????¨scanf??????????????¨???*/
  
  return 0;
}/*main??¨???*/ 


int h1(int a, int num)
{
  return a%num;
}

int h2 (int b, int num)
{
  return 1 + b%(num-1);
}