#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    map<string, int> mp;
    REP(i, n){
        ll a; string b; cin >> a;
        if(a==0){
            int c;
            cin >> b >> c;
            mp[b] = c;
        }else if(a==1){
            cin >> b;
            cout << mp[b] << endl;
        }else if(a==2){
            cin >> b;
            mp.erase(b);
        }else if(a==3){
            string c;
            cin >> b >> c;
            for(auto it=mp.lower_bound(b); it!=mp.upper_bound(c); ++it){
                if((*it).second) cout << (*it).first << " " << (*it).second << endl;
            }
            
        }
    }
	return 0;
}
