#include<stdio.h>
#include<string.h>
int c[20000001];
char ch[20],a[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(a)){
        if(!t) c[x]=1;
        return c[x];
    }
    return search(k+1,x+C(a[k])*y,y*4,t);
}

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