#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 4;
set<int> tree[maxn];
vector<int> v;
char p[maxn][10];
int x[maxn], y[maxn];
int num[maxn * 8];
void update(int o, int l, int r, int t, int value) {
  if (l == r) {
    num[o] = value;
    return;
  }
  int m = (l + r) >> 1;
  if (t <= m)
    update(o << 1, l, m, t, value);
  else
    update(o << 1 | 1, m + 1, r, t, value);
  num[o] = max(num[o << 1], num[o << 1 | 1]);
}
int query(int o, int l, int r, int L, int R, int value) {
  if (num[o] <= value) return -1;
  if (l == r) return l;
  int m = (l + r) >> 1;
  int k1 = -1, k2 = -1;
  if (L <= m && num[o << 1] > value) {
    k1 = query(o << 1, l, m, L, R, value);
    if (k1 != -1) return k1;
  }
  if (R >= m + 1 && num[o << 1 | 1] > value)
    k2 = query(o << 1 | 1, m + 1, r, L, R, value);
  return k2;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(num, 0, sizeof(num));
    for (int i = 0; i < n; i++) {
      scanf("%s%d%d", p[i], &x[i], &y[i]);
      if (p[i][0] != 'f') v.push_back(x[i]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int m = v.size();
    for (int i = 0; i < n; i++) {
      if (p[i][0] == 'a' || p[i][0] == 'r') {
        int t = lower_bound(v.begin(), v.end(), x[i]) - v.begin();
        if (p[i][0] == 'a')
          tree[t].insert(y[i]);
        else if (p[i][0] == 'r')
          tree[t].erase(y[i]);
        int value;
        if (tree[t].empty())
          value = -1e9;
        else {
          value = *--tree[t].end();
        }
        update(1, 0, m - 1, t, value);
      } else {
        int t = upper_bound(v.begin(), v.end(), x[i]) - v.begin();
        int z = query(1, 0, m - 1, t, m - 1, y[i]);
        if (z == -1 || t == m) {
          printf("-1\n");
          continue;
        }
        int ans = *tree[z].upper_bound(y[i]);
        printf("%d %d\n", v[z], ans);
      }
    }
  }
  return 0;
}
