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

int main(){
	int n;
	scanf("%d", &n);
	map<string, int> s;
	for(int i = 0; i < n; i++) {
		int id;
		scanf("%d", &id);
		string key;
		cin >> key;
		if(id == 0) {
			int x;
			scanf("%d", &x);
			auto p = s.emplace(key, x);
			if(!p.second) (*s.find(key)).second = x;
		}else if(id == 1) {
			auto itr = s.find(key);
			printf("%d\n", (itr != s.end()) ? (*itr).second : 0);
		}else if(id == 2) {
			s.erase(key);
		}
	}
}

