#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


map<string,int> MAP;

int main(){

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

	int command,x;

	for(int loop = 0; loop < num_query; loop++){

		string tmp;
		scanf("%d",&command);

		if(command == 0){

			cin >> tmp >> x;
			MAP[tmp] = x;

		}else{

			cin >> tmp;

			if(command == 1){

				auto at = MAP.find(tmp);

				if(at == MAP.end()){

					printf("0\n");
				}else{

					printf("%d\n",MAP[tmp]);
				}
			}else{

				MAP.erase(tmp);
			}
		}
	}

	return 0;
}

