#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> distr;
int mrand() { return distr(rng); }
struct Node {
  int key, prior;
  long long cap;
  long long min, finish;
  int id;
  int left, right;
  int leftmost, rightmost;
  Node(int _key, long long _cap, int _id) : key(_key), cap(_cap), id(_id) {
    prior = mrand();
    min = finish = 0;
    left = right = 0;
    leftmost = rightmost = id;
  }
  Node(){};
  void show() { printf("%d %d %lld %lld %lld\n", id, key, cap, min, finish); }
  void recalc();
  void dfs();
};
const int N = (int)1e5 + 5;
int sz = 1;
Node treap[2 * N];
int build(int key, int cap) {
  treap[sz] = Node(key, cap, sz);
  return sz++;
}
long long get_min(int T) { return T ? treap[T].min : 0; }
long long get_finish(int T) { return T ? treap[T].finish : 0; }
void Node::recalc() {
  leftmost = (left ? treap[left].leftmost : id);
  rightmost = (right ? treap[right].rightmost : id);
  long long Tmin = get_min(left);
  long long Tfinish = get_finish(left);
  if (left)
    Tfinish += (key - treap[treap[left].rightmost].key) *
               treap[treap[left].rightmost].cap;
  Tmin = std::min(Tmin, Tfinish);
  if (right) Tfinish += (treap[treap[right].leftmost].key - key) * cap;
  Tmin = std::min(Tmin, Tfinish + get_min(right));
  Tfinish += get_finish(right);
  Tmin = std::min(Tmin, Tfinish);
  min = Tmin;
  finish = Tfinish;
}
void Node::dfs() {
  show();
  if (left) printf("%d->left\n", id), treap[left].dfs();
  if (right) printf("%d->right\n", id), treap[right].dfs();
}
void recalc(int T) {
  if (!T) return;
  treap[T].recalc();
}
int merge(int T1, int T2) {
  if (!T1) return T2;
  if (!T2) return T1;
  if (treap[T1].prior > treap[T2].prior) {
    treap[T2].left = merge(T1, treap[T2].left);
    recalc(T2);
    return T2;
  } else {
    treap[T1].right = merge(treap[T1].right, T2);
    recalc(T1);
    return T1;
  }
}
void split(int T, int key, int& T1, int& T2) {
  if (!T) {
    T1 = T2 = 0;
    return;
  }
  if (key < treap[T].key) {
    split(treap[T].left, key, T1, T2);
    treap[T].left = T2;
    T2 = T;
  } else {
    split(treap[T].right, key, T1, T2);
    treap[T].right = T1;
    T1 = T;
  }
  recalc(T);
}
void insert(int& T, int key, int val) {
  int T1, T2;
  split(T, key - 1, T1, T2);
  T = merge(merge(T1, build(key, val)), T2);
}
void erase(int& T, int key) {
  int T1, T2, T3;
  split(T, key - 1, T1, T2);
  split(T2, key, T2, T3);
  T = merge(T1, T3);
}
double calc(long long start, long long time, long long cap) {
  if (start == 0) return time;
  if (cap >= 0) return -1;
  return time - double(start) / cap;
}
double get_ans(int T, long long start) {
  if (!T) return -1;
  while (true) {
    if (start + treap[T].min > 0) {
      return calc(start + treap[T].finish, treap[treap[T].rightmost].key,
                  treap[treap[T].rightmost].cap);
    }
    double tm, sp;
    if (treap[T].left) {
      if (start + treap[treap[T].left].min <= 0) {
        T = treap[T].left;
        continue;
      }
      start += get_finish(treap[T].left);
      tm = treap[treap[treap[T].left].rightmost].key;
      sp = treap[treap[treap[T].left].rightmost].cap;
      if (start + (treap[T].key - tm) * sp <= 0) {
        return calc(start, tm, sp);
      }
      start += (treap[T].key - tm) * sp;
    }
    if (treap[T].right) {
      tm = treap[treap[treap[T].right].leftmost].key;
      sp = treap[T].cap;
      if (start + (tm - treap[T].key) * sp <= 0) {
        return calc(start, treap[T].key, sp);
      }
      start += (tm - treap[T].key) * sp;
      T = treap[T].right;
    }
  }
}
void dfsT(int T) {
  if (!T) return;
  printf("\n\n");
  treap[T].dfs();
  printf("\n\n");
}
int main() {
  int q;
  scanf("%d", &q);
  int T = 0;
  for (int i = 0; i < q; ++i) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int t, cap;
      scanf("%d %d", &t, &cap);
      insert(T, t, cap);
    }
    if (type == 2) {
      int t;
      scanf("%d", &t);
      erase(T, t);
    }
    if (type == 3) {
      int l, r, start;
      scanf("%d %d %d", &l, &r, &start);
      if (start == 0) {
        printf("%d\n", l);
        continue;
      }
      int T1, T2, T3;
      split(T, l - 1, T1, T2);
      split(T2, r, T2, T3);
      double ans = get_ans(T2, start);
      if (ans < 0 || ans > r + 1e-9)
        printf("-1\n");
      else
        printf("%.15f\n", ans);
      T = merge(merge(T1, T2), T3);
    }
  }
}
