#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
struct Point {
  int x, y;
  bool operator<(Point &p) {
    if (x != p.x) return x < p.x;
    return y < p.y;
  }
  bool operator==(Point &p) { return x == p.x && y == p.y; }
};
template <class T>
struct SplayTree {
  int size[maxn], ch[maxn][2], P[maxn], stack[maxn], queue[maxn];
  int C, Top, root, *L, *R;
  T key[maxn], mx[maxn];
  int count;
  void init() {
    C = root = 0;
    count = 0;
    Top = 0;
    memset(ch, 0, sizeof(ch));
    memset(P, 0, sizeof(P));
    Point t;
    t.x = -0x7FFFFFFF;
    t.y = -0x7FFFFFFF;
    newNode(root, t);
    t.x = 0x7FFFFFFF;
    t.y = 0x7FFFFFFF;
    newNode(ch[root][1], t);
    P[C] = root;
    size[root] = 2;
    push_up(ch[root][1]);
    push_up(root);
    count = 2;
  }
  void rotate(int x, int f) {
    int y = P[x];
    ch[y][!f] = ch[x][f];
    P[ch[x][f]] = y;
    P[x] = P[y];
    if (P[x]) ch[P[y]][ch[P[y]][1] == y] = x;
    ch[x][f] = y;
    P[y] = x;
    push_up(y);
  }
  void splay(int x, int goal) {
    if (!x) return;
    while (P[x] != goal) {
      if (P[P[x]] == goal)
        rotate(x, ch[P[x]][0] == x);
      else {
        int y = P[x], z = P[y];
        int f = (ch[z][0] == y);
        if (ch[y][f] == x)
          rotate(x, !f), rotate(x, f);
        else
          rotate(y, f), rotate(x, f);
      }
    }
    push_up(x);
    if (goal == 0) root = x;
  }
  int select(int x, int i) {
    if (!x) return 0;
    int r = size[ch[x][0]] + 1;
    if (i == r)
      return x;
    else if (i < r)
      return select(ch[x][0], i);
    else
      return select(ch[x][1], i - r);
  }
  void rotateTo(int k, int goal) {
    int x = select(root, k);
    if (x) splay(x, goal);
  }
  void erase(int x) {
    int head = 0, tail = 0;
    for (queue[tail++] = x; head < tail; head++) {
      stack[Top++] = queue[head];
      if (ch[queue[head]][0]) queue[tail++] = ch[queue[head]][0];
      if (ch[queue[head]][1]) queue[tail++] = ch[queue[head]][1];
    }
  }
  void newNode(int &x, Point c) {
    if (Top)
      x = stack[--Top];
    else
      x = ++C;
    ch[x][0] = ch[x][1] = P[x] = 0;
    size[x] = 1;
    key[x] = mx[x] = c;
  }
  void push_up(int x) {
    key[0].x = -1;
    mx[0].x = -1;
    size[x] = 1 + size[ch[x][0]] + size[ch[x][1]];
    mx[x] = key[x];
    if (mx[ch[x][0]].y > mx[x].y) mx[x] = mx[ch[x][0]];
    if (mx[ch[x][1]].y > mx[x].y) mx[x] = mx[ch[x][1]];
  }
  void insert(T k) {
    int z;
    newNode(z, k);
    int x = root, y = 0;
    while (x) {
      y = x;
      if (k < key[x])
        x = ch[x][0];
      else
        x = ch[x][1];
    }
    P[z] = y;
    if (!y)
      root = z;
    else if (k < key[y])
      ch[y][0] = z;
    else
      ch[y][1] = z;
    splay(z, 0);
    count++;
  }
  void del(int z) {
    count--;
    int x, y, dest;
    if (!ch[z][0] || !ch[z][1]) {
      y = z;
    } else {
      y = next(z);
    }
    if (ch[y][0])
      x = ch[y][0];
    else
      x = ch[y][1];
    if (x) P[x] = P[y];
    if (!P[y])
      root = x;
    else if (y == ch[P[y]][0])
      ch[P[y]][0] = x;
    else
      ch[P[y]][1] = x;
    if (y != z) key[z] = key[y];
    splay(P[y], 0);
    stack[Top++] = y;
  }
  int min(int x) {
    while (ch[x][0]) x = ch[x][0];
    return x;
  }
  int max(int x) {
    while (ch[x][1]) x = ch[x][1];
    return x;
  }
  int next(int x) {
    if (ch[x][1]) return min(ch[x][1]);
    int y = P[x];
    while (y && x == ch[y][1]) {
      x = y;
      y = P[y];
    }
    return y;
  }
  int pre(int x) {
    if (ch[x][0]) return max(ch[x][0]);
    int y = P[x];
    while (y && x == ch[y][0]) {
      x = y;
      y = P[y];
    }
    return y;
  }
  int search(T &k) {
    int x = root;
    while (x && !(k == key[x])) {
      if (k < key[x])
        x = ch[x][0];
      else
        x = ch[x][1];
    }
    if (x) splay(x, 0);
    return x;
  }
  T &operator[](int i) { return key[i]; }
  void add(int x, int y) {
    Point t;
    t.x = x;
    t.y = y;
    insert(t);
  }
  void remove(int x, int y) {
    Point t;
    t.x = x;
    t.y = y;
    del(search(t));
  }
  void prt(int x) {
    if (x) {
      prt(ch[x][0]);
      printf("%d,%d\n", key[x].x, key[x].y);
      prt(ch[x][1]);
    }
  }
  void prt() { prt(root); }
  void query(int x, int y) {
    Point t;
    t.x = x + 1;
    t.y = -0x7FFFFFFF;
    insert(t);
    rotateTo(count, root);
    int idx = (ch[ch[root][1]][0]);
    if (!idx) {
      printf("-1\n");
    } else {
      if (mx[idx].y <= y) {
        printf("-1\n");
      } else {
        int ans = -0x77FF;
        int current = idx;
        while (current && mx[current].y > y) {
          if (key[current].y > y) {
            if (ans < 0 || key[current] < key[ans]) {
              ans = current;
            }
          }
          if (mx[ch[current][0]].y > y)
            current = ch[current][0];
          else
            current = ch[current][1];
        }
        printf("%d %d\n", key[ans].x, key[ans].y);
      }
    }
    t.x = x + 1;
    t.y = -0x7FFFFFFF;
    del(search(t));
  }
};
SplayTree<Point> tree;
int N;
void work() {
  tree.init();
  char temp[100];
  int p, q;
  for (int i = 1; i <= N; i++) {
    scanf("%s%d%d", temp, &p, &q);
    if (temp[0] == 'a')
      tree.add(p, q);
    else if (temp[0] == 'r')
      tree.remove(p, q);
    else
      tree.query(p, q);
  }
}
int main() {
  scanf("%d", &N);
  int num = 0;
  {
    ++num;
    work();
  }
  return 0;
}
