#include <bits/stdc++.h>

using namespace std;
map<string,int> mp;
map<string,int>::iterator itr;

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, q, val;
    string key,L,R;
    cin>>n;
    while(n--){
        cin>>q;
        switch (q)
        {
            case 0:
                cin>>key>>val;
                //mp.insert(make_pair(key,val));
                mp[key]=val;
                break;

            case 1:
                cin>>key;
                itr=mp.find(key);
                if(itr!=mp.end()) cout<<itr->second<<endl;
                else cout<<0<<endl;
                break;
            case 2:
                cin>>key;
                mp.erase(key);
                break;
            case 3:
                cin>>L>>R;

                map<string,int>::iterator end,it;
                it=mp.lower_bound(L);
                end=mp.upper_bound(R);
                for(;it!=end;it++)
                    cout<<(*it).first<<" "<<(*it).second<<endl;
                break;
        }
    }
    return 0;
}

