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

struct wordNode {
    long word_long;
    struct wordNode *next;
};
typedef struct wordNode * wordNodePtr;

void init(void);
int char2int(char in);
long str2long(char *in_str);
void insert(char *in_str);
bool find(char *target_str);

int main(void)
{
    init();

    int num_op;
    scanf("%d", &num_op);

    char op[6];
    char word_str[13];

    while (num_op--) {
        scanf("%s %s", op, word_str);
        if (strcmp(op, "insert") == 0) {
            insert(word_str);
        } else if (strcmp(op, "find") == 0) {
            bool yn = find(word_str);
            if (yn == true) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        } else {
            printf("ERROR! main\n");
        }
    }

    return 0;
}

wordNodePtr root;

void init(void)
{
    root = malloc(sizeof(struct wordNode));
    root->next = root;
}

int char2int(char in)
{
    if (in == 'A') {
        return 1;
    } else if (in == 'C') {
        return 2;
    } else if (in == 'G') {
        return 3;
    } else if (in == 'T') {
        return 4;
    } else {
        printf("ERROR! char2int\n");
        return -1;
    }
}

long str2long(char *in_str)
{
    int i;
    int p = 1;
    int in_long = 0;
    for (i = 0; i < (int)(strlen(in_str)); i++) {
        in_long += p * char2int(in_str[i]);
        p *= 5;
    }

    return in_long;
}

void insert(char *in_str)
{
    wordNodePtr insertee;
    insertee = malloc(sizeof(struct wordNode));
    long in_long = str2long(in_str);
    insertee->word_long = in_long;
    insertee->next = root->next;
    root->next = insertee;
}

bool find(char *target_str)
{
    long target_long = str2long(target_str);
    wordNodePtr current = root->next;
    while (current != root) {
        if (current->word_long == target_long) {
            return true;
        }
        current = current->next;
    }
    return false;
}