#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map> // insert the header
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int q = 0 , type = 0 , score = 0;
string name ;
map<string,int> m ;
cin >> q ;
for(int i = 0 ; i < q ; i++)
{
cin >> type ;
if(type == 1)
{
cin >> name >> score ;
m[name] += score ;
}
else if(type == 2)
{
cin >> name ;
m.erase(name) ;
}
else if(type == 3)
{
cin >> name ;
if( m.find(name) == m.end())
{
cout << "0\n" ;
}
else
{
cout << m[name] << endl ;
}
}
}
return 0;
}