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

#define MAXLEN	32768
#define ASTR	0x1
#define CSTR	0x2
#define GSTR	0x4
#define TSTR	0x8

int gdict1[MAXLEN+1];
int gdict21[MAXLEN+1],gdict22[MAXLEN+1];
int gdict31[MAXLEN+1],gdict32[MAXLEN+1],gdict33[MAXLEN+1], gstrlen;

int getKey( char *str, int start, int end )
{
	int key,i;

	key=0;	
	if( start <= gstrlen ) {
		for ( i=start; '\0'!=str[i] && i<=end; i++ ) {
			key=key<<4;
			if( 'A' == str[i] ) {
				key|=ASTR;
			} else if( 'C' == str[i] ) {
				key|=CSTR;
			} else if( 'G' == str[i] ) {
				key|=GSTR;
			} else if( 'T' == str[i] ) {
				key|=TSTR;
			}
		}
	}
	return key;
}
void insertStr( char *str )
{
	if( gstrlen < 4 ) {
		gdict1[ getKey( str, 0, 3 ) ]=1;
	} else if( 4 < gstrlen && gstrlen < 8 ) {
		gdict21[ getKey( str, 0, 3 ) ]=1;	
		gdict22[ getKey( str, 4, 7 ) ]=1;	
	} else {
		gdict31[ getKey( str, 0, 3 ) ]=1;	
		gdict32[ getKey( str, 4, 7 ) ]=1;	
		gdict33[ getKey( str, 8, 11 ) ]=1;
	}
	return;
}

int isExistStr( char *str )
{
	if( gstrlen < 4 ) {
		return gdict1[ getKey( str, 0, 3 ) ];
	} else if( 4 < gstrlen && gstrlen < 8 ) {
		return gdict21[ getKey( str, 0, 3 ) ]&&gdict22[ getKey( str, 4, 7 ) ];	
	} else {
		return gdict31[ getKey( str, 0, 3 ) ]&&gdict32[ getKey( str, 4, 7 ) ]&&gdict33[ getKey( str, 8, 11 ) ];	
	}
}
     
int main( void ) 
{
    int n;
 	char str[14];  
 	char com[8]; 
    int i;
       
    scanf( "%d", &n );
    for( i=0; i<n; i++ ) {
        scanf( "%s%s", com, str );
    	gstrlen = strlen( str ); 
        if( 'i' == com[0] ) {
        	insertStr( str );
        } else {
	        if( 1==isExistStr( str ) ) {
		        printf( "yes\n" );
		    } else {
		        printf( "no\n" );
		    }		    
	    }
    }

    return 0;
}