#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int n;
map<string,int>S;
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int c;string s;cin>>c>>s;
    if(c==0)
    {
      int x;cin>>x;S[s]=x;
    }
    else if(c==1)
    {
      cout<<S[s]<<endl;
      if(S[s]==0)S.erase(s);
    }
    else if(c==2)S.erase(s);
    else
    {
      string t;cin>>t;
      map<string,int>::iterator a=S.lower_bound(s),b=S.upper_bound(t);
      for(map<string,int>::iterator it=a;it!=b;it++)cout<<it->first<<" "<<it->second<<endl;
    }
  }
}

