#include <bits/stdc++.h>
using namespace std;

int main() {
  int q; cin >> q;
  map<string, int> mp;
  for (int i = 0; i < q; i++) {
    int cmd; cin >> cmd;
    if (cmd == 0) {
      string key; int x; cin >> key >> x;
      mp[key] = x;
    }
    if (cmd == 1) {
      string key; cin >> key;
      auto itr = mp.find(key);
      if (itr != mp.end()) {
        cout << mp[key] << endl;
      } else {
        cout << 0 << endl;
      }
    }
    if (cmd == 2) {
      string key; cin >> key;
      mp.erase(key);
    }
  }
}

