#include <bits/stdc++.h>
using namespace std;
//Long ago in the digital realm of Byteonia
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
unordered_map<int, string> hashTable;
for (int i = 0; i < N; i++) {
string cmd; cin >> cmd;
if (cmd == "INSERT") {
int key; string value;
cin >> key >> value;
hashTable[key] = value; // Insert or update
}
else if (cmd == "DELETE") {
int key; cin >> key;
hashTable.erase(key); // Delete if exists, else no effect
}
else if (cmd == "SEARCH") {
int key; cin >> key;
auto it = hashTable.find(key);
if (it == hashTable.end())
cout << "NOT_FOUND\n";
else
cout << it->second << "\n";
}
}
return 0;
}