#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
using namespace std;
map<string,int>a;
int main()
{
    int n,choose,temp,l,r;
    string color;
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d ", &choose);
        switch (choose)
        {
        case 0:
            cin >> color >> temp;
            //scanf("%s%d", color, &temp);
            a[color] = temp;
            break;
        case 1:
            cin >> color;
            if (a.find(color) != a.end())printf("%d\n", a[color]);
            else printf("0\n");
            break;
        case 2:
            cin >> color;
            a.erase(color);
            break;
        case 3:
            string p, q;
            cin >> p >> q;
            map<string, int>::iterator begin, end;
            begin = a.lower_bound(p);
            end = a.upper_bound(q);
            for (; begin != end; begin++)
            {
                cout << (*begin).first <<" "<<(*begin).second<< endl;
            }
        }
    }
    
}
