#include <stdio.h>
#include <string.h>
int A[20000001];
char b[20],c[20];
int C(char x) {
  if(x=='A') return 1;
  if(x=='C') return 2;
  if(x=='G') return 3;
  return 4;
}
int search(int k, int x, int y, int t) {
  if(k==strlen(c)) {
    if(!t) A[x]=1;
    return A[x];
  }
  return search(k+1,x+C(c[k])*y,y*4,t);
}

int main() {
  int n;
  scanf("%d",&n);
  while(n--) {
    scanf("%s %s",b,c);
    if(b[0]=='i') search(0,0,1,0);
    else {
      if(search(0,0,1,1)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

