#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    int q;
    cin >> q;
    map<string, int> map;
    while (q--)
    {
        int c;
        cin >> c;
        if (c == 0)
        {
            string key;
            int x;
            cin >> key >> x;
            map[key] = x;
        } else if (c == 1)
        {
            string key;
            cin >> key;
            auto it = map.find(key);
            if (it != map.end())
            {
                cout << it->second << endl;
            } else cout << 0 << endl;
        } else
        {
            string key;
            cin>>key;
            map.erase(key);
        }


    }

}
