#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


map<string,int>SMS;
map<string,int>::iterator it;


int main()
{
   // FI;
    int test;
    scanf("%d",&test);
    while(test--)
    {
        int cs;
        scanf("%d",&cs);
        switch(cs)
        {
        case 0:
            {
                string s;
                int a;
                cin>>s>>a;
                SMS[s]=a;
            }
            break;
        case 1:
            {
                string s;
                cin>>s;
                it = SMS.find(s);
                cout<<it->second<<"\n";
            }
            break;
        case 2:
            {
                string s;
                cin>>s;
                SMS.erase(s);
            }
            break;
        case 3:
            {
                string a,b;
                cin>>a>>b;
                it = SMS.lower_bound(a);
                for(;it!=SMS.upper_bound(b);it++)
                    cout<<it->first<<" "<<it->second<<"\n";
            }
            break;
        default:
            break;
        }
    }
    return 0;
}


