#include <bits/stdc++.h>
using namespace std;
struct info {
  int op, t, s, l, r, v;
} a[100007];
int b[100007], s[100007], e[100007 * 4];
long long pre[100007 * 4], sum[100007 * 4], tag[100007 * 4];
int find(int l, int r, int x) {
  int res = r;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (b[mid] >= x)
      res = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  return res;
}
int lst(int k, int l, int r, int x) {
  if (r <= x)
    if (e[k])
      if (l == r)
        return l;
      else {
        int mid = (l + r) >> 1;
        if (e[k * 2 + 1])
          return lst(k * 2 + 1, mid + 1, r, x);
        else
          return lst(k * 2, l, mid, x);
      }
    else
      return -1;
  int mid = (l + r) >> 1;
  if (x > mid) {
    int tmp = lst(k * 2 + 1, mid + 1, r, x);
    if (tmp != -1) return tmp;
  }
  return lst(k * 2, l, mid, x);
}
int nxt(int k, int l, int r, int x) {
  if (x <= l)
    if (e[k])
      if (l == r)
        return l;
      else {
        int mid = (l + r) >> 1;
        if (e[k * 2])
          return nxt(k * 2, l, mid, x);
        else
          return nxt(k * 2 + 1, mid + 1, r, x);
      }
    else
      return -1;
  int mid = (l + r) >> 1;
  if (x <= mid) {
    int tmp = nxt(k * 2, l, mid, x);
    if (tmp != -1) return tmp;
  }
  return nxt(k * 2 + 1, mid + 1, r, x);
}
void put(int k, int l, int r, int x) {
  if (l == r) {
    e[k] = x > 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (abs(x) <= mid)
    put(k * 2, l, mid, x);
  else
    put(k * 2 + 1, mid + 1, r, x);
  e[k] = e[k * 2] | e[k * 2 + 1];
}
void up(int k) {
  if (pre[k * 2] < sum[k * 2] + pre[k * 2 + 1])
    pre[k] = pre[k * 2];
  else
    pre[k] = sum[k * 2] + pre[k * 2 + 1];
  sum[k] = sum[k * 2] + sum[k * 2 + 1];
}
void push(int k, int l, int mid, int r) {
  sum[k * 2] += tag[k] * (b[mid + 1] - b[l]);
  if (sum[k * 2] > 0)
    pre[k * 2] = 0;
  else
    pre[k * 2] = sum[k * 2];
  tag[k * 2] += tag[k];
  sum[k * 2 + 1] += tag[k] * (b[r + 1] - b[mid + 1]);
  if (sum[k * 2 + 1] > 0)
    pre[k * 2 + 1] = 0;
  else
    pre[k * 2 + 1] = sum[k * 2 + 1];
  tag[k * 2 + 1] += tag[k];
  tag[k] = 0;
}
void upd(int k, int l, int r, int L, int R, int delta) {
  if (L <= l && r <= R) {
    sum[k] += 1LL * delta * (b[r + 1] - b[l]);
    if (sum[k] > 0)
      pre[k] = 0;
    else
      pre[k] = sum[k];
    tag[k] += delta;
    return;
  }
  int mid = (l + r) >> 1;
  if (tag[k]) push(k, l, mid, r);
  if (L <= mid) upd(k * 2, l, mid, L, R, delta);
  if (R > mid) upd(k * 2 + 1, mid + 1, r, L, R, delta);
  up(k);
}
long long base;
int pos(int k, int l, int r, int L) {
  if (L <= l) {
    if (pre[k] <= base)
      if (l == r)
        return l + 1;
      else {
        int mid = (l + r) >> 1;
        if (tag[k]) push(k, l, mid, r);
        if (pre[k * 2] <= base)
          return pos(k * 2, l, mid, L);
        else {
          base -= sum[k * 2];
          return pos(k * 2 + 1, mid + 1, r, L);
        }
      }
    else {
      base -= sum[k];
      return -1;
    }
  }
  int mid = (l + r) >> 1;
  if (tag[k]) push(k, l, mid, r);
  if (L <= mid) {
    int tmp = pos(k * 2, l, mid, L);
    if (tmp != -1) return tmp;
  }
  return pos(k * 2 + 1, mid + 1, r, L);
}
long long get(int k, int l, int r, int L, int R) {
  if (L <= l && r <= R) return sum[k];
  int mid = (l + r) >> 1;
  if (tag[k]) push(k, l, mid, r);
  long long res = 0;
  if (L <= mid) res += get(k * 2, l, mid, L, R);
  if (R > mid) res += get(k * 2 + 1, mid + 1, r, L, R);
  return res;
}
int main() {
  int q, n = 0;
  scanf("%d", &q);
  b[++n] = 0, b[++n] = 1000000001;
  for (int i = 1; i <= q; ++i) {
    scanf("%d", &a[i].op);
    if (a[i].op == 1) scanf("%d%d", &a[i].t, &a[i].s), b[++n] = a[i].t;
    if (a[i].op == 2) scanf("%d", &a[i].t);
    if (a[i].op == 3) scanf("%d%d%d", &a[i].l, &a[i].r, &a[i].v);
  }
  sort(b + 1, b + n + 1);
  n = unique(b + 1, b + n + 1) - b - 1;
  put(1, 1, n, 1), put(1, 1, n, n);
  for (int i = 1; i <= q; ++i) {
    if (a[i].op == 1) {
      int x = find(1, n, a[i].t);
      int l = lst(1, 1, n, x), r = nxt(1, 1, n, x + 1);
      put(1, 1, n, x);
      upd(1, 1, n - 1, x, r - 1, a[i].s - s[l]);
      s[x] = a[i].s;
    }
    if (a[i].op == 2) {
      int x = find(1, n, a[i].t);
      int l = lst(1, 1, n, x - 1), r = nxt(1, 1, n, x + 1);
      put(1, 1, n, -x);
      upd(1, 1, n - 1, x, r - 1, s[l] - s[x]);
    }
    if (a[i].op == 3)
      if (!a[i].v)
        printf("%d\n", a[i].l);
      else {
        int x = find(1, n, a[i].l);
        x = nxt(1, 1, n, x);
        base = -a[i].v;
        int y = pos(1, 1, n - 1, x);
        if (y == -1)
          puts("-1");
        else {
          int l = lst(1, 1, n, y - 1);
          base = a[i].v + get(1, 1, n - 1, x, l - 1);
          double ans = (double)base / (-s[l]) + b[l];
          if (ans > (double)a[i].r)
            puts("-1");
          else
            printf("%.8f\n", ans);
        }
      }
  }
}
