#include <iostream>
#include <stdio.h>
#include <string>
#include <map>

using namespace std;

int main()
{
    map<string, int> M;
    int query, command, value;
    string key, L, R;
    map<string, int>::iterator itr, itrlow, itrup;
    scanf("%d", &query);
    for (int i = 0; i < query; i++)
    {
        scanf("%d", &command);
        switch (command) {
        case 0:
            cin >> key >> value;
            M[key] = value;
            break;
        case 1:
            cin >> key;
            if (M.find(key) == M.end())
            {
                printf("%d\n", 0);
            }
            else
            {
                printf("%d\n", M[key]);
            }

            break;
        case 2:
            cin >> key;
            M.erase(key);
            break;
        case 3:
            cin >> L >> R;
            itrlow = M.lower_bound(L);
            itrup = M.upper_bound(R);
            while (itrlow != itrup) {
                cout << itrlow->first << " " << itrlow->second << "\n";
                itrlow++;
            }

        default:
            break;
        }
    }
    return 0;
}


// erasing from map
#include <iostream>
#include <map>
#include <string>

int main1()
{
  map<string, int> map1;
  map<string, int>::iterator itr;
  string str1 = "aaa";
  string str2 = "bbb";
  string str3 = "ccc";
  map1[str1] = 10;
  map1[str2] = 20;
  map1[str3] = 30;
  map1.erase(str1);
  for (itr=map1.begin(); itr!=map1.end(); ++itr)
    std::cout << itr->first << " => " << itr->second << '\n';

  return 0;
}

