#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int n, m;
int Max[maxn << 2];
int L[maxn << 2];
int R[maxn << 2];
set<int> st[maxn];
int a[maxn];
char ch[maxn][8];
int x[maxn], y[maxn];
int LL(int k) { return k << 1; }
int RR(int k) { return k << 1 | 1; }
void build(int l, int r, int k) {
  Max[k] = -1;
  L[k] = l;
  R[k] = r;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, LL(k));
  build(mid + 1, r, RR(k));
}
void up(int k) { Max[k] = Max[LL(k)] > Max[RR(k)] ? Max[LL(k)] : Max[RR(k)]; }
void update(int k, int val, int pos) {
  if (L[k] == R[k]) {
    if (!st[pos].empty())
      Max[k] = (*(--st[pos].end()));
    else
      Max[k] = -1;
    return;
  }
  int mid = (L[k] + R[k]) >> 1;
  if (pos <= mid) update(LL(k), val, pos);
  if (pos > mid) update(RR(k), val, pos);
  up(k);
}
int query(int l, int r, int k, int val) {
  if (r < l) return -1;
  if (L[k] == R[k]) {
    return L[k];
  }
  int mid = (L[k] + R[k]) >> 1;
  int ret = -1;
  if (l <= mid && val < Max[LL(k)]) {
    ret = query(l, r, LL(k), val);
  }
  if (ret == -1 && r > mid && val < Max[RR(k)]) {
    ret = query(l, r, RR(k), val);
  }
  return ret;
}
int main() {
  int pos;
  int i, j;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%s%d%d", ch[i], &x[i], &y[i]);
      a[i] = x[i];
      st[i].clear();
    }
    sort(a, a + n);
    m = unique(a, a + n) - a;
    build(0, m - 1, 1);
    for (i = 0; i < n; i++) {
      pos = lower_bound(a, a + m, x[i]) - a;
      if (ch[i][0] == 'a') {
        st[pos].insert(y[i]);
        update(1, y[i], pos);
      } else if (ch[i][0] == 'f') {
        if (a[pos] == x[i]) pos++;
        int ret = query(pos, m - 1, 1, y[i]);
        if (ret == -1)
          printf("%d\n", ret);
        else
          printf("%d %d\n", a[ret], *st[ret].upper_bound(y[i]));
      } else if (ch[i][0] == 'r') {
        st[pos].erase(y[i]);
        update(1, -1, pos);
      }
    }
  }
  return 0;
}
