#include<stdio.h>
#include<string.h>

#define TABLE_SIZE 100

typedef struct {
    int id;
    char name[50];
    int status;
} StudentRecord;

StudentRecord hashTable[TABLE_SIZE];

void initHashTable() {
    for (int i = 0;  i < TABLE_SIZE; i++) {
        hashTable[i].status = 0;
        
    }
}

int hashFunction(int id) {
    return  id % TABLE_SIZE;
}

void insert(int id, char* name) {
    int index = hashFunction(id);
    int orginalIndex = index;
    while (hashTable[index].status == 1) {
        if (hashTable[index].id == id) {
            printf("No\n");
            return;
        }
        
        index = (index + 1) % TABLE_SIZE;
        if (index == orginalIndex) {
            printf("No\n");
            return;
        }
    }
    if (hashTable[index].status == 0 || hashTable[index].status == 2) {
        hashTable[index].id = id;
        strcpy(hashTable[index].name, name);
        hashTable[index].status = 1;
        printf("Yes\n");
    }
}
void delete(int id) {
    int index = hashFunction(id);
    int originalIndex = index;
    while (hashTable[index].status != 0) {
        if (hashTable[index].status == 1 && hashTable[index].id == id) {
            hashTable[index].status = 2;
            printf ("Yes\n");
            return;
        }
        index = (index + 1) % TABLE_SIZE;
        if (index == originalIndex) break;
    }
    printf("No\n");
}

void search(int id) {
    int index = hashFunction(id);
    int originalIndex = index;
    while (hashTable[index].status != 0) {
        if (hashTable[index].status == 1 && hashTable[index].id == id) {
            printf("%s\n", hashTable[index].name);
            return;
        }
        index = (index + 1) % TABLE_SIZE;
        if (index == originalIndex) break;
    }
    printf("No\n");
}

int main() {
    initHashTable();
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int type, id;
        char name[50];
        scanf("%d %d", &type, &id);
        if (type == 1 || type == 2) scanf("%[^\n]", name);
        
        switch(type) {
            case 1: insert(id, name); break;
            case 2: update(id, name); break;
            case 3: delete(id); break;
            case 4: search(id); break;
            defalut: printf("Invalid input\n");
        }
    }
    return 0;
}