#include <stdio.h> 
int main() {
  char HIRA[1<<21], Ryo[256],cg;
  unsigned int an, as, at;
  Ryo['A'] = 4;
  Ryo['C'] = 3;
  Ryo['G'] = 2;
  Ryo['T'] = 1;
  scanf("%d", &an);
  getchar();
  while (an--) {
    as = 0;
    at = 1;
    int hata = ( cg = getchar() ) == 'i';
    while ( ( cg = getchar() ) != ' ' );
    while ( ( cg = Ryo[getchar()] ) != 0 ) {
      as += cg * t;
      at *= 4;
    }
    if ( hata ) HIRA[as] = 1; else puts( HIRA[as] ? "yes" : "no" );
  }
  return 0;
}