#include <bits/stdc++.h>

using namespace std;


int main(){
    int num_query;
    int command,val;
    char key[20];
    char L[20],R[20];
    scanf("%d",&num_query);
    map<string,int> map_array;

    for(int i = 0;i < num_query;i++){
        scanf("%d %s",&command,key);
        if(command == 0){
            scanf("%d",&val);
            map_array[key] = val;
        }else if(command == 1){
            if(map_array.find(key) != map_array.end()) printf("%d\n",map_array[key]);
            else printf("0\n");
        }else if(command == 2){
            if(map_array.find(key) != map_array.end()) map_array.erase(key);
        }else if(command == 3){
            scanf("%s",R);
            map<string,int>::iterator itr = map_array.lower_bound(key);
            while(itr != map_array.upper_bound(R)){
                printf("%s %d\n",itr->first.c_str(),itr->second);
                itr++;
            }
        }
    }

    return 0;   
}

