#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int N = 1 << 20;
long long lazy[N << 1], val[N << 1], sum[N << 1], mul[N << 1], mn[N << 1],
    mnpos[N << 1];
void pd(int i, int l, int r) {
  if (lazy[i] != -1e18) {
    val[i] = lazy[i];
    sum[i] = lazy[i] * mul[i];
    if (0 <= sum[i])
      mn[i] = 0, mnpos[i] = l;
    else
      mn[i] = sum[i], mnpos[i] = r;
    if (i < N) {
      lazy[i << 1] = lazy[i];
      lazy[i << 1 | 1] = lazy[i];
    }
    lazy[i] = -1e18;
  }
}
void upd(int a, int b, int i, int l, int r, int v) {
  pd(i, a, b);
  if (l <= a && b <= r) {
    lazy[i] = v;
    pd(i, a, b);
    return;
  }
  if (r <= a || b <= l) return;
  int md = (a + b) >> 1;
  upd(a, md, i << 1, l, r, v);
  upd(md, b, i << 1 | 1, l, r, v);
  sum[i] = sum[i << 1] + sum[i << 1 | 1];
  if (mn[i << 1] <= sum[i << 1] + mn[i << 1 | 1])
    mn[i] = mn[i << 1], mnpos[i] = mnpos[i << 1];
  else
    mn[i] = sum[i << 1] + mn[i << 1 | 1], mnpos[i] = mnpos[i << 1 | 1];
}
void upd(int l, int r, int v) { upd(0, N, 1, l, r, v); }
long long qry(int a, int b, int i, int l, int r) {
  pd(i, a, b);
  if (l <= a && b <= r) return sum[i];
  if (r <= a || b <= l) return 0;
  int md = (a + b) >> 1;
  long long L = qry(a, md, i << 1, l, r);
  long long R = qry(md, b, i << 1 | 1, l, r);
  return L + R;
}
long long qry(int l, int r) { return qry(0, N, 1, l, r); }
struct YYY {
  long long sum, mn;
  YYY() {}
  YYY(long long a, long long b) : sum(a), mn(b) {}
};
YYY yyy[N << 1];
void qryyy(int a, int b, int i, int l, int r) {
  pd(i, a, b);
  if (l <= a && b <= r) {
    yyy[i] = YYY(sum[i], mn[i]);
    return;
  }
  if (r <= a || b <= l) {
    yyy[i] = YYY(0, 0);
    return;
  }
  int md = (a + b) >> 1;
  qryyy(a, md, i << 1, l, r);
  qryyy(md, b, i << 1 | 1, l, r);
  yyy[i].sum = yyy[i << 1].sum + yyy[i << 1 | 1].sum;
  if (yyy[i << 1].mn < yyy[i << 1].sum + yyy[i << 1 | 1].mn)
    yyy[i].mn = yyy[i << 1].mn;
  else
    yyy[i].mn = yyy[i << 1].sum + yyy[i << 1 | 1].mn;
}
void qryyy(int l, int r) { qryyy(0, N, 1, l, r); }
int qryans(int a, int b, int i, int l, int r, long long v) {
  pd(i, a, b);
  if (r <= a || b <= l) return -1;
  int md = (a + b) >> 1;
  if (i < N) {
    pd(i << 1, a, md);
    pd(i << 1 | 1, md, b);
    long long lsum, rsum, lmn, rmn;
    if (l <= a && b <= r) {
      lsum = sum[i << 1];
      lmn = mn[i << 1];
      rsum = sum[i << 1 | 1];
      rmn = mn[i << 1 | 1];
    } else {
      lsum = yyy[i << 1].sum;
      lmn = yyy[i << 1].mn;
      rsum = yyy[i << 1 | 1].sum;
      rmn = yyy[i << 1 | 1].mn;
    }
    if (lmn + v <= 0) return qryans(a, md, i << 1, l, r, v);
    if (lsum + rmn + v <= 0) return qryans(md, b, i << 1 | 1, l, r, v + lsum);
    return -1;
  } else
    return mn[i] + v <= 0 ? mnpos[i] : -1;
}
int qryans(int l, int r, int v) { return qryans(0, N, 1, l, r, v); }
long long qrys(int a, int b, int i, int x) {
  pd(i, a, b);
  if (a + 1 == b) return val[i];
  int md = (a + b) >> 1;
  if (x < md) return qrys(a, md, i << 1, x);
  return qrys(md, b, i << 1 | 1, x);
}
long long qrys(int x) { return qrys(0, N, 1, x); }
struct query {
  int tp, A, B, C;
  query() {}
  query(int a, int b, int c, int d) : tp(a), A(b), B(c), C(d) {}
};
vector<query> vquery;
vector<int> vtime;
struct event {
  int t, s;
  event() {}
  event(int a, int b) : t(a), s(b) {}
  bool operator<(const event &x) const { return t < x.t; }
};
set<event> events;
int getId(int tme) {
  return lower_bound(vtime.begin(), vtime.end(), tme) - vtime.begin();
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int t, s;
      scanf("%d%d", &t, &s);
      vquery.push_back(query(tp, t, s, -1));
      vtime.push_back(t);
    }
    if (tp == 2) {
      int t;
      scanf("%d", &t);
      vquery.push_back(query(tp, t, -1, -1));
    }
    if (tp == 3) {
      int l, r, v;
      scanf("%d%d%d", &l, &r, &v);
      vquery.push_back(query(tp, l, r, v));
      vtime.push_back(l);
      vtime.push_back(r);
    }
  }
  vtime.push_back(0);
  vtime.push_back(1e9);
  sort(vtime.begin(), vtime.end());
  vtime.erase(unique(vtime.begin(), vtime.end()), vtime.end());
  for (int i = 0; i < (N << 1); ++i) lazy[i] = -1e18;
  for (int i = 0; i + 1 < vtime.size(); ++i)
    mul[i + N] = vtime[i + 1] - vtime[i];
  for (int i = N - 1; ~i; --i) mul[i] = mul[i << 1] + mul[i << 1 | 1];
  for (int i = 0; i < n; ++i) {
    int tp = vquery[i].tp;
    if (tp == 1) {
      int t = vquery[i].A;
      int s = vquery[i].B;
      set<event>::iterator it, jt;
      events.insert(event(t, s));
      it = events.find(event(t, s));
      int nxt = 1e9;
      jt = it;
      if (jt != events.end()) {
        ++jt;
        if (jt != events.end()) {
          nxt = jt->t;
        }
      }
      int L = getId(t);
      int R = getId(nxt);
      upd(L, R, s);
    }
    if (tp == 2) {
      int t = vquery[i].A;
      set<event>::iterator it, jt, kt;
      it = events.lower_bound(event(t, -1e9));
      int s = it->s;
      it = events.erase(it);
      int lsts = 0;
      jt = it;
      if (jt != events.begin()) {
        --jt;
        lsts = jt->s;
      }
      int nxt = 1e9;
      if (it != events.end()) {
        nxt = it->t;
      }
      int L = getId(t);
      int R = getId(nxt);
      upd(L, R, lsts);
    }
    if (tp == 3) {
      int l = getId(vquery[i].A);
      int r = getId(vquery[i].B);
      int v = vquery[i].C;
      set<event>::iterator it = events.lower_bound(event(vtime[l], -1e9));
      int fst = 1e9;
      if (it != events.end()) fst = it->t;
      fst = getId(fst);
      int fsts = qrys(l);
      upd(l, fst, 0);
      double ans = -1;
      if (!v)
        ans = vtime[l];
      else {
        qryyy(l, r);
        int x = qryans(l, r, v);
        if (~x) {
          --x;
          ans = vtime[x];
          long long lft = qry(l, x);
          long long nws = -qrys(x);
          if (lft + v) ans += 1.0 * (lft + v) / nws;
          if (ans > vtime[r]) ans = -1;
        }
      }
      printf("%.7f\n", ans);
      upd(l, fst, fsts);
    }
  }
  return 0;
}
