#include <bits/stdc++.h>
using namespace std;
struct STree {
  vector<int64_t> sum;
  vector<int64_t> mn;
  vector<int> cnt;
  int sz;
  void build(int n) {
    sz = 1;
    while (sz < n) {
      sz *= 2;
    }
    sum.assign(sz * 2, 0);
    mn.assign(sz * 2, 0);
    cnt.assign(sz * 2, 0);
  }
  int xl, xr;
  int64_t x;
  int64_t _getSum(int v, int l, int r) {
    if (xl <= l && r <= xr) {
      return sum[v];
    } else if (r < xl || xr < l) {
      return 0;
    } else {
      int m = (l + r) / 2;
      return _getSum(v * 2, l, m) + _getSum(v * 2 + 1, m + 1, r);
    }
  }
  int64_t getSum(int l, int r) {
    xl = l;
    xr = r;
    return _getSum(1, 0, sz - 1);
  }
  void _setX(int v, int l, int r) {
    if (l == r) {
      sum[v] = x;
      mn[v] = x;
      cnt[v] += xr;
      ;
    } else {
      int m = (l + r) / 2;
      if (xl <= m) {
        _setX(v * 2, l, m);
      } else {
        _setX(v * 2 + 1, m + 1, r);
      }
      sum[v] = sum[v * 2] + sum[v * 2 + 1];
      mn[v] = min(mn[v * 2], mn[v * 2 + 1] + sum[v * 2]);
      cnt[v] += xr;
    }
  }
  void setX(int pos, int64_t val, int zp) {
    xl = pos;
    xr = zp;
    x = val;
    _setX(1, 0, sz - 1);
  }
  int _getPos(int v, int l, int r) {
    if (r < xl || mn[v] > x) {
      return -1;
    } else if (l == r) {
      return l;
    } else {
      int m = (l + r) / 2;
      int res = _getPos(v * 2, l, m);
      if (res == -1) {
        x -= sum[v * 2];
        res = _getPos(v * 2 + 1, m + 1, r);
        x += sum[v * 2];
      }
      return res;
    }
  }
  int getPos(int l, int64_t val) {
    xl = l;
    x = val;
    return _getPos(1, 0, sz - 1);
  }
  int _getMaxZp(int v, int l, int r) {
    if (cnt[v] == 0 || xr < l) {
      return -1;
    } else if (l == r) {
      return l;
    } else {
      int m = (l + r) / 2;
      int res = _getMaxZp(v * 2 + 1, m + 1, r);
      if (res == -1) {
        res = _getMaxZp(v * 2, l, m);
      }
      return res;
    }
  }
  int getMaxZp(int r) {
    xr = r;
    return _getMaxZp(1, 0, sz - 1);
  }
  int _getMinZp(int v, int l, int r) {
    if (cnt[v] == 0 || r < xl) {
      return -1;
    } else if (l == r) {
      return l;
    } else {
      int m = (l + r) / 2;
      int res = _getMinZp(v * 2, l, m);
      if (res == -1) {
        res = _getMinZp(v * 2 + 1, m + 1, r);
      }
      return res;
    }
  }
  int getMinZp(int l) {
    xl = l;
    return _getMinZp(1, 0, sz - 1);
  }
  void debug(int v, int l, int r) {
    cout << v << ' ' << l << ' ' << r << " | " << mn[v] << ' ' << sum[v] << ' '
         << cnt[v] << endl;
    if (l != r) {
      int m = (l + r) / 2;
      debug(v * 2, l, m);
      debug(v * 2 + 1, m + 1, r);
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  vector<int> qe(q);
  vector<pair<int, int>> add;
  vector<int> rm;
  vector<pair<pair<int, int>, int>> md;
  set<int> times;
  for (int i = 0; i < q; ++i) {
    cin >> qe[i];
    if (qe[i] == 1) {
      int t, s;
      cin >> t >> s;
      times.insert(t);
      add.push_back({t, s});
    } else if (qe[i] == 2) {
      int t;
      cin >> t;
      rm.push_back(t);
    } else {
      int l, r, v;
      cin >> l >> r >> v;
      times.insert(l);
      times.insert(r);
      md.push_back({{l, r}, v});
    }
  }
  int cur = 0;
  vector<int> uncom;
  map<int, int> compress;
  for (int v : times) {
    compress[v] = cur;
    ++cur;
    uncom.push_back(v);
  }
  STree s;
  s.build(cur);
  vector<int> states(cur, 2e+9);
  int p1 = 0, p2 = 0, p3 = 0;
  cout << fixed << setprecision(10);
  double dans = 0;
  for (int i = 0; i < q; ++i) {
    if (qe[i] == 1) {
      int ct = compress[add[p1].first];
      states[ct] = add[p1].second;
      int nx = s.getMinZp(ct);
      int pr = s.getMaxZp(ct);
      int64_t x = 2e+9 * 1ll * add[p1].second;
      if (nx != -1) {
        x = add[p1].second * 1ll * (uncom[nx] - add[p1].first);
      }
      s.setX(ct, x, 1);
      if (pr != -1) {
        x = states[pr] * 1ll * (add[p1].first - uncom[pr]);
        s.setX(pr, x, 0);
      }
      ++p1;
    } else if (qe[i] == 2) {
      int ct = compress[rm[p2]];
      states[ct] = 2e+9;
      s.setX(ct, 0, -1);
      int nx = s.getMinZp(ct);
      int pr = s.getMaxZp(ct);
      if (pr != -1) {
        int64_t x = (long long)(2e+9) * 1ll * states[pr];
        if (nx != -1) {
          x = states[pr] * 1ll * (uncom[nx] - uncom[pr]);
        }
        s.setX(pr, x, 0);
      }
      ++p2;
    } else {
      int l, r;
      int64_t v;
      l = md[p3].first.first;
      r = md[p3].first.second;
      v = md[p3].second;
      double ans;
      if (v == 0) {
        ans = l;
      } else {
        int ps = s.getPos(compress[l], -v + s.getSum(0, compress[l] - 1));
        if (ps == -1) {
        }
        if (ps == -1 || ps >= compress[r]) {
          ans = -1;
        } else {
          int64_t sm = s.getSum(compress[l], ps - 1);
          v += sm;
          ans = uncom[ps];
          if (states[ps] >= 0 || states[ps] * 1ll * (r - uncom[ps]) + v > 0) {
            ans = -1;
          } else {
            ans -= v * 1.0 / states[ps];
          }
        }
      }
      cout << ans << '\n';
      dans = ans;
      ++p3;
    }
  }
  return 0;
}
