#include<map> #include<set> #include<cmath> #include<queue> #include<bitset> #include<math.h> #include<cstdio> #include<vector> #include<string> #include<cstring> #include<iostream> #include<algorithm> #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; const int N=200010; const int MAX=1000000100; const int mod=100000000; const int MOD1=1000000007; const int MOD2=1000000009; const double EPS=0.00000001; typedef long long ll; const ll MOD=998244353; const int INF=1000000010; typedef double db; typedef unsigned long long ull; struct node { int op,x,y; node() {} node(int op,int x,int y):op(op),x(x),y(y) {} bool operator < (const node a) const { if (x!=a.x) return x<a.x; return y<a.y; } }ope[N],add[N]; char s[5]; int k,sum[4*N],mx[4*N]; void build(int x,int l,int r) { sum[x]=mx[x]=0; if (l==r) return ; int mid=(l+r)>>1; build(2*x,l,mid); build(2*x+1,mid+1,r); } int find_point(int x,int y) { int l=0,r=k,mid=k>>1;; while (l+1<r) if (add[mid].x>x||(add[mid].x==x&&add[mid].y>=y)) { r=mid;mid=(l+r)>>1; } else { l=mid;mid=(l+r)>>1; } return r; } void add_point(int x,int l,int r,int w,int z) { if (l==r) { mx[x]=z;return ; } int mid=(l+r)>>1; if (w<=mid) add_point(2*x,l,mid,w,z); else add_point(2*x+1,mid+1,r,w,z); mx[x]=max(mx[2*x],mx[2*x+1]); } void del_point(int x,int l,int r,int w) { if (l==r) { mx[x]=0;return ; } int mid=(l+r)>>1; if (w<=mid) del_point(2*x,l,mid,w); else del_point(2*x+1,mid+1,r,w); mx[x]=max(mx[2*x],mx[2*x+1]); } int get(int x) { int l=1,r=k+1,mid=(l+r)>>1; while (l+1<r) if (add[mid].x<=x) { l=mid;mid=(l+r)>>1; } else { r=mid;mid=(l+r)>>1; } return r; } int query(int x,int l,int r,int L,int R,int w) { if (L>R||mx[x]<=w) return 0; if (l==r) return l; int ret,mid=(l+r)>>1; if (R<=mid) return query(2*x,l,mid,L,R,w); else if (L>mid) return query(2*x+1,mid+1,r,L,R,w); else { ret=query(2*x,l,mid,L,mid,w); if (!ret) ret=query(2*x+1,mid+1,r,mid+1,R,w); return ret; } } int main() { int i,n,x,y,z; scanf("%d", &n); for (i=1;i<=n;i++) { scanf("%s%d%d", s, &x, &y); if (s[0]=='a') { ope[i]=node(1,x,y);add[++k]=node(1,x,y); } else if (s[0]=='r') ope[i]=node(2,x,y); else { ope[i]=node(3,x,y);add[++k]=node(1,x,y); } } sort(add+1,add+k+1); build(1,1,k); for (i=1;i<=n;i++) if (ope[i].op==1) add_point(1,1,k,find_point(ope[i].x,ope[i].y),ope[i].y); else if (ope[i].op==2) del_point(1,1,k,find_point(ope[i].x,ope[i].y)); else { z=query(1,1,k,get(ope[i].x),k,ope[i].y); if (!z) printf("-1\n"); else printf("%d %d\n", add[z].x, add[z].y); } return 0; }