#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110000;
struct Treap {
  struct Node {
    int ls, rs, wgt;
    int time, tL, tR;
    int speed, speedR;
    long long res, mn;
  } tr[MAXN];
  int cnt, root;
  int newNode(int p, int k) {
    int x = ++cnt;
    tr[x].ls = tr[x].rs = 0;
    tr[x].wgt = rand();
    tr[x].time = tr[x].tL = tr[x].tR = p;
    tr[x].speed = tr[x].speedR = k;
    tr[x].res = tr[x].mn = 0;
    return x;
  }
  void pushup(int x) {
    int lc = tr[x].ls, rc = tr[x].rs;
    if (lc && rc) {
      tr[x].tL = tr[lc].tL;
      tr[x].tR = tr[rc].tR;
      tr[x].speedR = tr[rc].speedR;
      tr[x].res = tr[x].mn = 0;
      tr[x].mn = min(tr[x].mn, tr[lc].mn);
      tr[x].res += tr[lc].res + 1ll * tr[lc].speedR * (tr[x].time - tr[lc].tR);
      tr[x].mn = min(tr[x].mn, tr[x].res);
      tr[x].res += 1ll * tr[x].speed * (tr[rc].tL - tr[x].time);
      tr[x].mn = min(tr[x].mn, tr[x].res + tr[rc].mn);
      tr[x].res += tr[rc].res;
    } else if (lc) {
      tr[x].tL = tr[lc].tL;
      tr[x].tR = tr[x].time;
      tr[x].speedR = tr[x].speed;
      tr[x].res = tr[x].mn = 0;
      tr[x].mn = min(tr[x].mn, tr[lc].mn);
      tr[x].res += tr[lc].res + 1ll * tr[lc].speedR * (tr[x].time - tr[lc].tR);
      tr[x].mn = min(tr[x].mn, tr[x].res);
    } else if (rc) {
      tr[x].tL = tr[x].time;
      tr[x].tR = tr[rc].tR;
      tr[x].speedR = tr[rc].speedR;
      tr[x].res = tr[x].mn = 0;
      tr[x].res += 1ll * tr[x].speed * (tr[rc].tL - tr[x].time);
      tr[x].mn = min(tr[x].mn, tr[x].res + tr[rc].mn);
      tr[x].res += tr[rc].res;
    } else {
      tr[x].tL = tr[x].tR = tr[x].time;
      tr[x].speedR = tr[x].speed;
      tr[x].res = tr[x].mn = 0;
    }
  }
  void split(int o, int& x, int& y, int p) {
    if (!o) {
      x = y = 0;
      return;
    }
    if (tr[o].time < p)
      x = o, split(tr[o].rs, tr[x].rs, y, p);
    else
      y = o, split(tr[o].ls, x, tr[y].ls, p);
    pushup(o);
  }
  void merge(int x, int y, int& o) {
    if (!x || !y) {
      o = x + y;
      return;
    }
    if (tr[x].wgt < tr[y].wgt)
      o = x, merge(tr[x].rs, y, tr[o].rs);
    else
      o = y, merge(x, tr[y].ls, tr[o].ls);
    pushup(o);
  }
  void insert(int p, int k) {
    int a, b, c;
    split(root, a, b, p);
    merge(a, newNode(p, k), c);
    merge(c, b, root);
  }
  void erase(int p) {
    int a, b, c, d;
    split(root, a, b, p);
    split(b, c, d, p + 1);
    merge(a, d, root);
  }
  void print(int x) {
    if (!x) return;
    print(tr[x].ls);
    printf("%d %d %d %d %d %lld %lld\n", x, tr[x].ls, tr[x].rs, tr[x].time,
           tr[x].speed, tr[x].res, tr[x].mn);
    print(tr[x].rs);
  }
  double query(int l, int r, long long v) {
    if (v == 0) return l;
    int a, b, c, d, e, x, y;
    split(root, a, b, l);
    split(b, c, d, r);
    merge(c, y = newNode(r, 0), e);
    x = e;
    while (1) {
      long long t1 = tr[x].ls
                         ? tr[tr[x].ls].res + 1ll * tr[tr[x].ls].speedR *
                                                  (tr[x].time - tr[tr[x].ls].tR)
                         : 0;
      long long t2 =
          tr[x].rs ? 1ll * tr[x].speed * (tr[tr[x].rs].tL - tr[x].time) : 0;
      if (tr[x].ls && v + min(tr[tr[x].ls].mn, t1) <= 0)
        x = tr[x].ls;
      else if (tr[x].rs && v + t1 + t2 > 0)
        v += t1 + t2, x = tr[x].rs;
      else {
        v += t1;
        break;
      }
    }
    double res = x != y ? tr[x].time - 1.0 * v / tr[x].speed : -1;
    split(e, b, c, r);
    merge(a, b, c);
    merge(c, d, root);
    return res;
  }
} treap;
int main() {
  srand(1);
  int q;
  scanf("%d", &q);
  while (q--) {
    int opt;
    scanf("%d", &opt);
    if (opt == 1) {
      int p, k;
      scanf("%d%d", &p, &k);
      treap.insert(p, k);
    } else if (opt == 2) {
      int p;
      scanf("%d", &p);
      treap.erase(p);
    } else {
      int l, r, v;
      scanf("%d%d%d", &l, &r, &v);
      printf("%.7lf\n", treap.query(l, r, v));
    }
  }
  return 0;
}
