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

int main()
{
    map<string, int> m;

    int n;
    cin >> n;

    while (n--)
    {
        int x;
        int y;
        string z, a;

        cin >> x;
        if (x == 0)
        {
            cin >> z >> y;
            //m.insert(make_pair(z, y));
            m[z] = y;
        }
        if (x == 1)
        {
            cin >> z;
            cout << m[z] << endl;
        }
        if (x == 2)
        {
            cin >> z;
            m.erase(z);
        }
        if (x == 3)
        {
            cin >> z >> a;
            for (auto it = m.lower_bound(z); it != m.upper_bound(a); it++)
            {
                if (it->second)
                    cout << it->first << ' ' << it->second << endl;
            }
        }
    }
    return 0;
}
