#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  map<string, int> M;
  while (q--) {
    int op;
    cin >> op;
    if (op == 0) {
      string k;
      int x;
      cin >> k >> x;
      M[k] = x;
    } else if (op == 1) {
      string k;
      cin >> k;
      cout << M[k] << endl;
    } else if (op == 2) {
      string k;
      cin >> k;
      M[k] = 0;
    } else {
      string l, r;
      cin >> l >> r;
      auto left = M.lower_bound(l);
      auto right = M.upper_bound(r);
      for (auto it = left; it != right; it++) {
        if (it->second)
          cout << it->first << " " << it->second << endl;
      }
    }
  }
}
