#include <bits/stdc++.h>
using namespace std;
int gi() {
  int x = 0, w = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') w = 0, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return w ? x : -x;
}
const int N = 1e5 + 5;
int ls[N], rs[N], tim[N], spd[N], tL[N], tR[N], spdR[N], rd[N], tot, rt;
long long res[N], mn[N];
void up(int x) {
  tL[x] = tR[x] = tim[x];
  spdR[x] = spd[x];
  mn[x] = res[x] = 0;
  if (ls[x]) {
    tL[x] = tL[ls[x]];
    mn[x] = min(mn[x], mn[ls[x]]);
    res[x] += res[ls[x]] + 1ll * spdR[ls[x]] * (tim[x] - tR[ls[x]]);
    mn[x] = min(mn[x], res[x]);
  }
  if (rs[x]) {
    tR[x] = tR[rs[x]];
    spdR[x] = spdR[rs[x]];
    res[x] += 1ll * spd[x] * (tL[rs[x]] - tim[x]);
    mn[x] = min(mn[x], res[x] + mn[rs[x]]);
    res[x] += res[rs[x]];
    mn[x] = min(mn[x], res[x]);
  }
}
void split(int x, int k, int &a, int &b) {
  if (!x) {
    a = b = 0;
    return;
  }
  if (tim[x] <= k)
    a = x, split(rs[x], k, rs[a], b), up(a);
  else
    b = x, split(ls[x], k, a, ls[b]), up(b);
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  if (rd[x] < rd[y])
    return rs[x] = merge(rs[x], y), up(x), x;
  else
    return ls[y] = merge(x, ls[y]), up(y), y;
}
double query(int x, int r, long long v) {
  if (!x) return -1;
  if (ls[x]) {
    if (v + mn[ls[x]] <= 0) return query(ls[x], tim[x], v);
    v += res[ls[x]] + 1ll * spdR[ls[x]] * (tim[x] - tR[ls[x]]);
    if (v <= 0) return tim[x] - 1.0 * v / spdR[ls[x]];
  }
  if (rs[x]) {
    v += 1ll * spd[x] * (tL[rs[x]] - tim[x]);
    if (v <= 0) return tL[rs[x]] - 1.0 * v / spd[x];
    if (v + mn[rs[x]] <= 0) return query(rs[x], r, v);
    v += res[rs[x]];
  }
  v += 1ll * spdR[x] * (r - tR[x]);
  if (v <= 0) return r - 1.0 * v / spdR[x];
  return -1;
}
void dfs(int x) {
  if (ls[x]) dfs(ls[x]);
  if (rs[x]) dfs(rs[x]);
  up(x);
}
int main() {
  int querycnt = 0;
  int q = gi();
  while (q--) {
    int op = gi();
    if (op == 1) {
      tim[++tot] = gi();
      spd[tot] = gi();
      rd[tot] = rand() * rand();
      int x, y;
      split(rt, tim[tot], x, y);
      up(tot);
      rt = merge(x, merge(tot, y));
    } else if (op == 2) {
      int t = gi(), x, y, z;
      split(rt, t, x, z);
      split(x, t - 1, x, y);
      rt = merge(x, z);
    } else {
      int l = gi(), r = gi(), v = gi(), x, y, z;
      if (!v) {
        printf("%d\n", l);
        continue;
      }
      split(rt, r, x, z);
      split(x, l - 1, x, y);
      printf("%.6lf\n", query(y, r, v));
      rt = merge(x, merge(y, z));
    }
  }
  return 0;
}
