#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100;
long long inf = 4e18;
struct Query {
  int typ, t, cap, l, r, v;
} Q[N];
struct node {
  long long sum, mn;
  node() { sum = 0, mn = 0; }
  node(long long s, long long m) { sum = s, mn = m; }
} tr[4 * N];
node Merge(node a, node b) {
  node ret;
  ret.sum = a.sum + b.sum;
  ret.mn = min(a.mn, a.sum + b.mn);
  return ret;
}
void upd(int cn, int b, int e, int i, long long x) {
  if (b > i or e < i) {
    return;
  }
  int lc = 2 * cn, rc = lc + 1, mid = (b + e) / 2;
  if (b >= i and e <= i) {
    tr[cn].sum += x;
    tr[cn].mn += x;
    return;
  }
  upd(lc, b, mid, i, x);
  upd(rc, mid + 1, e, i, x);
  tr[cn] = Merge(tr[lc], tr[rc]);
}
node query(int cn, int b, int e, int i, int j) {
  if (b > j or e < i) return node(0, inf);
  if (b >= i and e <= j) {
    return tr[cn];
  }
  int lc = 2 * cn, rc = lc + 1, mid = (b + e) / 2;
  return Merge(query(lc, b, mid, i, j), query(rc, mid + 1, e, i, j));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(10) << fixed;
  int q;
  cin >> q;
  set<int> allt;
  for (int i = 1; i <= q; i++) {
    cin >> Q[i].typ;
    if (Q[i].typ == 1) {
      cin >> Q[i].t >> Q[i].cap;
      allt.insert(Q[i].t);
    } else if (Q[i].typ == 2) {
      cin >> Q[i].t;
      allt.insert(Q[i].t);
    } else {
      cin >> Q[i].l >> Q[i].r >> Q[i].v;
    }
  }
  allt.insert(0);
  allt.insert(2e9);
  map<int, int> Mt, revt;
  int kkk = 0;
  for (int x : allt) {
    Mt[x] = ++kkk;
    revt[kkk] = x;
  }
  set<int> times;
  times.insert(kkk);
  times.insert(1);
  map<int, int> caps;
  caps[kkk] = 0;
  caps[1] = 0;
  for (int i = 1; i <= q; i++) {
    if (Q[i].typ == 1) {
      int tt = Mt[Q[i].t];
      int c = Q[i].cap;
      auto it = times.lower_bound(tt);
      long long d = (revt[*it] - Q[i].t);
      upd(1, 1, kkk, tt, 1ll * c * d);
      it--;
      int prev_t = *it;
      upd(1, 1, kkk, prev_t, -1ll * caps[prev_t] * d);
      caps[tt] = c;
      times.insert(tt);
    } else if (Q[i].typ == 2) {
      int tt = Mt[Q[i].t];
      int c = caps[tt];
      auto it = times.upper_bound(tt);
      long long d = (revt[*it] - Q[i].t);
      upd(1, 1, kkk, tt, -1ll * c * d);
      it--;
      it--;
      int prev_t = *it;
      upd(1, 1, kkk, prev_t, +1ll * caps[prev_t] * d);
      times.erase(tt);
      caps[tt] = 0;
    } else {
      if (Q[i].v == 0) {
        cout << Q[i].l << "\n";
        continue;
      }
      if (Q[i].l == Q[i].r) {
        cout << "-1"
             << "\n";
        continue;
      }
      int l = *allt.lower_bound(Q[i].l);
      auto itt = allt.upper_bound(Q[i].r);
      itt--;
      int r = *itt;
      if (l > r) {
        cout << "-1"
             << "\n";
        continue;
      }
      l = Mt[l], r = Mt[r];
      int lo = l, hi = r, v = Q[i].v;
      if (query(1, 1, kkk, lo, hi).mn + v > 0)
        cout << "-1"
             << "\n";
      else {
        while (hi > lo) {
          int mid = (hi + lo) >> 1;
          if (query(1, 1, kkk, l, mid).mn + v <= 0)
            hi = mid;
          else
            lo = mid + 1;
        }
        long long lage = abs(-query(1, 1, kkk, l, lo - 1).sum - v);
        double ans = revt[lo] + 1.0 * lage / abs(caps[lo]);
        if (ans > Q[i].r) {
          cout << "-1"
               << "\n";
        } else {
          cout << ans << "\n";
        }
      }
    }
  }
  return 0;
}
