#include <bits/stdc++.h>
using namespace std;
int n, m;
int i, j, k, l;
int q[222222][3];
map<int, set<int> > c;
map<int, int> cpr;
int cp[222222];
int t[(1 << 19) + 3], d, inf = 1e9;
void upd(int i, int v) {
  i += d;
  t[i] = v;
  for (i >>= 1; i; i >>= 1)
    t[i] = ((t[i * 2]) > (t[i * 2 + 1]) ? (t[i * 2]) : (t[i * 2 + 1]));
}
int fndmax(int l, int r, int mx) {
  int i = l + d, k = 1;
  while (i % k == 0 && l + k - 1 <= r) k <<= 1;
  k >>= 1;
  int res = r + 1;
  for (; l <= r && k > 0;) {
    if (t[i / k] > mx) {
      res = l + k - 1;
      k >>= 1;
    } else {
      l += k;
      i += k;
      k = 1;
      while (i % k == 0 && l + k - 1 <= r) k <<= 1;
      k >>= 1;
    }
  }
  return res;
}
int main() {
  scanf("%d", &m);
  int x, y;
  char st[111];
  set<int> ax;
  for (i = 0; i < m; ++i) {
    scanf("%s%d%d", &st, &q[i][1], &q[i][2]);
    q[i][0] = (*st == 'a' ? '+' : (*st == 'r' ? '-' : '?'));
    ax.insert(q[i][1]);
  }
  n = 0;
  for (typeof((ax).begin()) it = (ax).begin(); it != (ax).end(); it++) {
    cp[n] = *it;
    ;
    cpr[*it] = n++;
  }
  for (d = 1; d < n; d <<= 1)
    ;
  for (i = 0; i < d + d; ++i) t[i] = -inf;
  for (k = 0; k < m; ++k) {
    x = q[k][1];
    y = q[k][2];
    if (q[k][0] == '+') {
      i = cpr[x];
      c[x].insert(y);
      upd(i, *c[x].rbegin());
    } else if (q[k][0] == '-') {
      i = cpr[x];
      c[x].erase(y);
      upd(i, c[x].size() == 0 ? -inf : *c[x].rbegin());
    } else {
      i = cpr[x];
      i = fndmax(i + 1, n - 1, y);
      if (i == n) {
        printf("-1\n");
        continue;
      }
      set<int> &sy = c[cp[i]];
      set<int>::iterator it = sy.upper_bound(y);
      printf("%d %d\n", cp[i], *it);
    }
  }
  return 0;
}
