/* 二维的线段树跟一维的似乎一样的 身高建为x轴 活泼度为y轴 */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define LL(x) ((x) << 1) #define RR(x) ((x) << 1 | 1) using namespace std; const int N = 100; struct Sub_tree { int l, r; double love; int mid() { return (l + r) >> 1; } }; struct Main_tree { int lh, rh; int mid() { return (lh + rh) >> 1; } Sub_tree active[30 * N]; } high[3 * N]; inline bool readint(int &ret) { int sgn; char c; c = getchar(); if (c == EOF) return true; while (c != '-' && c < '0' || c > '9') c = getchar(); sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0'); ret *= sgn; return false; } inline bool readdouble(double &ret) { int sgn; double bit = 0.1; char c; c = getchar(); if (c == EOF) return true; while (c != '-' && c != '.' && (c < '0' || c > '9')) c = getchar(); sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0'); if (c == ' ' || c == '/n') { ret *= sgn; return true; } while ((c = getchar()) >= '0' && c <= '9') ret += (c - '0') * bit, bit /= 10; ret *= sgn; return false; } inline void Sub_Build(int fa, int node, int l, int r) { high[fa].active[node].l = l; high[fa].active[node].r = r; high[fa].active[node].love = -1; if (l == r) return; int mid = (l + r) >> 1; Sub_Build(fa, LL(node), l, mid); Sub_Build(fa, RR(node), mid + 1, r); } inline void Build(int node, int lh, int rh, int l, int r) { high[node].lh = lh; high[node].rh = rh; Sub_Build(node, 1, l, r); if (lh == rh) { return; } int mid = (lh + rh) >> 1; Build(LL(node), lh, mid, l, r); Build(RR(node), mid + 1, rh, l, r); } inline void Sub_Update(int fa, int node, int act, double love) { high[fa].active[node].love = max(love, high[fa].active[node].love); if (high[fa].active[node].l == high[fa].active[node].r) { return; } int mid = high[fa].active[node].mid(); //int mid = (high[fa].active[node].l + high[fa].active[node].r) >> 1; if (act <= mid) Sub_Update(fa, LL(node), act, love); else Sub_Update(fa, RR(node), act, love); high[fa].active[node].love = max(high[fa].active[LL(node)].love, high[fa].active[RR(node)].love); } inline void Update(int node, int hig, int act, double love) { Sub_Update(node, 1, act, love); if (high[node].lh == high[node].rh) { return; } if (hig <= high[LL(node)].rh) Update(LL(node), hig, act, love); else Update(RR(node), hig, act, love); } inline double Sub_Query(int fa, int node, int l, int r) { //puts("2"); if (high[fa].active[node].l == l && high[fa].active[node].r == r) { return high[fa].active[node].love; } int mid = high[fa].active[node].mid(); //int mid = (high[fa].active[node].l + high[fa].active[node].r) >> 1; //printf("Sub_Query mid :: %d/n", mid); if (r <= mid) { return Sub_Query(fa, LL(node), l, r); } else if (l > mid) { return Sub_Query(fa, RR(node), l, r); } else { return max(Sub_Query(fa, LL(node), l, mid), Sub_Query(fa, RR(node), mid + 1, r)); } } inline double Query(int node, int lh, int rh, int l, int r) { //puts("1"); if (high[node].lh == lh && high[node].rh == rh) { //puts("3"); return Sub_Query(node, 1, l, r); } int mid = high[node].mid(); //int mid = (high[node].lh + high[node].rh) >> 1; //printf("mid :: %d/n", mid); if (rh <= mid) { return Query(LL(node), lh, rh, l, r); } else if (lh > mid) { return Query(RR(node), lh, rh, l, r); } else { return max(Query(LL(node), lh, mid, l, r), Query(RR(node), mid + 1, rh, l, r)); } } inline void Swep(int &a, int &b) { if (a > b) { int temp = a; a = b; b = temp; } } int main() { int n; while (scanf("%d", &n) != EOF && n) { char str[2]; int hig; double active, love; int lh, rh; double lactive, ractive; Build(1, 100, 200, 0, 1000); //puts("Build"); while (n--) { scanf("%s", str); if (str[0] == 'I') { //scanf("%d %lf %lf", &hig, &active, &love); readint(hig); readdouble(active); readdouble(love); int tt = (int) (10 * active); Update(1, hig, tt, love); //puts("Update"); } else { //scanf("%d %d %lf %lf", &lh, &rh, &lactive, &ractive); readint(lh); readint(rh); readdouble(lactive); readdouble(ractive); //Swep(lh, rh); if (lh > rh) { int temp = lh; lh = rh; rh = temp; } if (lactive > ractive) { double temp = lactive; lactive = ractive; ractive = temp; } //printf("%d %d %lf %lf/n", lh, rh, lactive, ractive); double ans = Query(1, lh, rh, (int) (10 * lactive), (int) (10 * ractive)); //puts("Query"); if (ans == -1) { puts("-1"); continue; } printf("%0.1lf/n", ans); } } } }