#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long double eps = 1e-8;
struct node {
  long long x, y = rand() << 16 + rand();
  long long speed = 0, tL = INF, tR = -INF, speedR = 0, res = 0, mn = 0;
  node *l = NULL, *r = NULL;
  node(){};
  node(long long x, long long speed)
      : x(x), tL(x), tR(x), speed(speed), speedR(speed){};
};
node* safe(node* a, long long x, long long speed) {
  return a == NULL ? new node(x, speed) : a;
}
void recalc(node* a) {
  if (a == NULL) return;
  node *nl = safe(a->l, a->x, 0), *nr = safe(a->r, a->x, a->speed);
  a->tL = min(a->x, nl->tL);
  a->tR = max(nr->tR, a->x);
  a->speedR = nr->speedR;
  long long mn = 0, res = 0;
  mn = min(mn, nl->mn);
  res += nl->res + nl->speedR * (a->x - nl->tR);
  mn = min(mn, res);
  res += a->speed * (nr->tL - a->x);
  mn = min(mn, res + nr->mn);
  res += nr->res;
  mn = min(mn, res);
  a->mn = mn;
  a->res = res;
}
node* merge(node* a, node* b) {
  if (a == NULL) {
    return b;
  }
  if (b == NULL) {
    return a;
  }
  if (a->y > b->y) {
    a->r = merge(a->r, b);
    recalc(a);
    return a;
  }
  b->l = merge(a, b->l);
  recalc(b);
  return b;
}
pair<node*, node*> split(node* a, long long x) {
  if (a == NULL) {
    return make_pair(a, a);
  }
  if (a->x < x) {
    pair<node*, node*> t = split(a->r, x);
    a->r = t.first;
    t.first = a;
    recalc(a);
    return t;
  }
  pair<node*, node*> t = split(a->l, x);
  a->l = t.second;
  t.second = a;
  recalc(a);
  return t;
}
void add(node*& a, long long x, long long speed) {
  pair<node*, node*> t = split(a, x);
  pair<node*, node*> t1 = split(t.second, x + 1);
  t1.first = new node(x, speed);
  t.second = merge(t1.first, t1.second);
  a = merge(t.first, t.second);
}
void del(node*& a, long long x) {
  pair<node*, node*> t = split(a, x);
  pair<node*, node*> t1 = split(t.second, x + 1);
  a = merge(t.first, t1.second);
}
long double go_down(node* a, long long v, long long r) {
  if (a == NULL) return (v == 0 ? 0 : -1);
  node *nl = safe(a->l, a->x, a->speed), *nr = safe(a->r, a->x, a->speed);
  long long mn = 0, res = 0;
  mn = min(mn, nl->mn);
  if (mn + v <= 0) return go_down(a->l, v, r);
  res += nl->res + nl->speedR * (a->x - nl->tR);
  mn = min(mn, res);
  if (mn + v <= 0) return a->x - (((long double)mn + v) / nl->speedR);
  res += a->speed * (nr->tL - a->x);
  if (res + v <= 0) return nr->tL - (((long double)res + v) / a->speed);
  if (res + nr->mn + v > 0) {
    if (a->speedR < 0) {
      long double ac = a->tR - ((long double)res + nr->res + v) / a->speedR;
      if (ac <= r) return ac;
    }
    return -1;
  }
  return go_down(a->r, res + v, r);
}
long double get(node* a, long long l, long long r, long long v) {
  if (v == 0) return l;
  if (a == NULL) return -1;
  pair<node*, node*> t = split(a, l);
  pair<node*, node*> t1 = split(t.second, r + 1);
  long double ans = go_down(t1.first, v, r);
  t.second = merge(t1.first, t1.second);
  a = merge(t.first, t.second);
  return ans;
}
int main() {
  int q;
  cin >> q;
  node* a = NULL;
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      long long t, s;
      cin >> t >> s;
      add(a, t, s);
    } else if (type == 2) {
      long long t;
      cin >> t;
      del(a, t);
    } else {
      long long l, r, v;
      cin >> l >> r >> v;
      cout.precision(20);
      printf("%.7f\n", (double)get(a, l, r, v));
    }
  }
}
