#include <bits/stdc++.h>
using namespace std;
using uid = uniform_int_distribution<int>;
using ll = long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uid rn(1, 2e9);
struct node {
  node *l, *r;
  int time, priority, speed;
  int timeL, timeR, speedR;
  ll patience, minv;
  node(){};
  node(int t, int s) {
    time = t;
    speed = s;
    priority = rn(rng);
    timeL = timeR = time;
    speedR = speed;
    patience = 0;
    minv = 0;
    l = nullptr;
    r = nullptr;
  }
  node *attach(node *L, node *R) {
    l = L;
    r = R;
    if (l == nullptr && r == nullptr) {
      timeL = timeR = time;
      patience = 0;
      minv = 0;
      speedR = speed;
      return this;
    }
    if (l == nullptr) {
      timeL = time;
      timeR = r->timeR;
      speedR = r->speedR;
      ll aft = ll(speed) * (r->timeL - time);
      patience = aft + r->patience;
      minv = min(0LL, aft + r->minv);
      return this;
    }
    if (r == nullptr) {
      timeR = time;
      timeL = l->timeL;
      speedR = speed;
      ll aft = l->patience + ll(l->speedR) * (time - l->timeR);
      patience = aft;
      minv = min(l->minv, aft);
      return this;
    }
    timeL = l->timeL;
    timeR = r->timeR;
    speedR = r->speedR;
    ll aft1 = l->patience + ll(l->speedR) * (time - l->timeR);
    ll aft2 = aft1 + ll(speed) * (r->timeL - time);
    patience = aft2 + r->patience;
    minv = min({l->minv, aft1, aft2 + r->minv});
    return this;
  }
};
void _print(node *n) {
  if (n == nullptr) return;
  cout << "(";
  _print(n->l);
  cout << ")";
  cout << n->time << " (";
  _print(n->r);
  cout << ")";
}
void print(node *n) {
  _print(n);
  cout << endl;
}
node *merge(node *a, node *b) {
  if (a == nullptr) return b;
  if (b == nullptr) return a;
  if (a->priority < b->priority) return a->attach(a->l, merge(a->r, b));
  return b->attach(merge(a, b->l), b->r);
}
pair<node *, node *> split(node *n, int t) {
  if (n == nullptr) return {nullptr, nullptr};
  if (n->time <= t) {
    auto p = split(n->r, t);
    return {n->attach(n->l, p.first), p.second};
  } else {
    auto p = split(n->l, t);
    return {p.first, n->attach(p.second, n->r)};
  }
}
node *root;
void insert(int t, int s) {
  auto p = split(root, t);
  root = merge(p.first, merge(new node(t, s), p.second));
}
void del(int t) {
  auto p = split(root, t);
  auto p2 = split(p.first, t - 1);
  root = merge(p2.first, p.second);
}
double bs(ll v, node *n) {
  if (n == nullptr) return -1;
  if (n->l != nullptr && v + n->l->minv <= 0) return bs(v, n->l);
  ll aft = v;
  if (n->l != nullptr) {
    aft = v + n->l->patience + ll(n->l->speedR) * (n->time - n->l->timeR);
    if (aft <= 0)
      return double(n->l->timeR) -
             double(v + n->l->patience) / double(n->l->speedR);
  }
  if (n->r == nullptr) return -1;
  ll aft2 = aft + ll(n->speed) * ll(n->r->timeL - n->time);
  if (aft2 <= 0) return double(n->time) - double(aft) / double(n->speed);
  return bs(aft2, n->r);
}
double query(int l, int r, int v) {
  if (v == 0) return l;
  auto p = split(root, l - 1);
  auto p2 = split(p.second, r);
  node *n = p2.first;
  if (n == nullptr) {
    root = merge(p.first, merge(p2.first, p2.second));
    return -1;
  }
  double res = bs(v, n);
  if (res < 0 && ll(v) + n->patience + ll(n->speedR) * (r - n->timeR) <= 0)
    res = double(n->timeR) - double(ll(v) + n->patience) / double(n->speedR);
  root = merge(p.first, merge(p2.first, p2.second));
  return res;
}
int q;
int main() {
  scanf("%d", &q);
  root = nullptr;
  while (q--) {
    int x, t, s, l, r, v;
    scanf("%d", &x);
    if (x == 1) {
      scanf("%d%d", &t, &s);
      insert(t, s);
    } else if (x == 2) {
      scanf("%d", &t);
      del(t);
    } else {
      scanf("%d%d%d", &l, &r, &v);
      double res = query(l, r, v);
      if (res < 0)
        printf("-1\n");
      else
        printf("%.9lf\n", query(l, r, v));
    }
  }
  return 0;
}
