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

int main(){
    int q;
    cin >> q;
    map<string, int> mp;
    for(int i=0; i<q; i++){
        int a;
        string key;
        cin >> a >> key;
        if(a == 0){
            int x;
            cin >> x;
            mp[key] = x;
        }else if(a == 1){
            auto itr = mp.find(key);
            if( itr != mp.end() ) {
                cout << mp[key] << endl;
            } else {
                cout << 0 << endl;
            }
        }else if(a == 2){
            mp.erase(key);
        }else{
            string r;
            cin >> r;
            auto left = mp.lower_bound(key);
            auto right = mp.upper_bound(r);
            for(auto itr = left; itr != right; ++itr) {
                cout << itr->first << " " << itr->second << endl;
            }
        }
    }
    return 0;
}
