#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct dictionary{
  struct dictionary *A, *C, *G, *T;
  int a, c, g, t;
} dictionary;
void Insert(void);
void Find(void);
dictionary *Tree;
int main(){
  int i, n;
  char func[6];
  Tree = (dictionary *)malloc(sizeof(dictionary) * 1);
  Tree->A = Tree->C = Tree->G = Tree->T = NULL;
  Tree->a = Tree->c = Tree->g = Tree->t = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",func);
    if(strcmp(func,"insert") == 0) Insert();
    else if(strcmp(func,"find") == 0) Find();
  }
  return 0;
}
void Insert(void){
  int i;
  char in[12];
  dictionary *n, *temp=Tree;
  scanf("%s",in);
  for(i=0; in[i]!='\0' ; i++){
    switch(in[i]){
      printf("%c\n",in[i]);
      case 'A':
      if(temp->A == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->A = n;
      }
      if(in[i+1] == '\0') temp->a = 1;
      temp = temp->A;
      break;
      case 'C':
      if(temp->C == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->C = n;
      }
      if(in[i+1] == '\0') temp->c = 1;
      temp = temp->C;
      break;
      case 'G':
      if(temp->G == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->G = n;
      }
      if(in[i+1] == '\0') temp->g = 1;
      temp = temp->G;
      break;
      case 'T':
      if(temp->T == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->T = n;
      }
      if(in[i+1] == '\0') temp->t = 1;
      temp = temp->T;
      break;
      default:
      break;
    }
  }
}
void Find(void){
  int i;
  char in[12];
  dictionary *temp=Tree;
  scanf("%s",in);
  // printf("%s\n",in);
  for(i=0; in[i]!='\0' ; i++){
    switch(in[i]){
      case 'A':
      if(temp->A == NULL || (in[i+1] == '\0' && !temp->a)){
        printf("no\n");
        return;
      }
      temp = temp->A;
      break;
      case 'C':
      if(temp->C == NULL || (in[i+1] == '\0' && !temp->c)){
        printf("no\n");
        return;
      }
      temp = temp->C;
      break;
      case 'G':
      if(temp->G == NULL || (in[i+1] == '\0' && !temp->g)){
        printf("no\n");
        return;
      }
      temp = temp->G;
      break;
      case 'T':
      if(temp->T == NULL || (in[i+1] == '\0' && !temp->t)){
        printf("no\n");
        return;
      }
      temp = temp->T;
      break;
      default:
      break;
    }
  }
  printf("yes\n");
}