#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
const long long LLINF = numeric_limits<long long>::max();
const unsigned long long ULLINF = numeric_limits<unsigned long long>::max();
const double PI = acos(-1.0);
int sz = 1;
vector<int> compressed;
vector<pair<int, pair<int, int>>> queries;
map<int, int> order;
vector<int> t;
vector<set<int>> vert;
void build(int n) {
  while (sz < n) sz <<= 1;
  t.resize(sz + sz, 0);
}
void update(int i) {
  i += sz;
  if (vert[i - sz].size() == 0)
    t[i] = 0;
  else
    t[i] = *vert[i - sz].rbegin();
  while ((i >> 1) > 0) {
    i >>= 1;
    t[i] = max(t[i + i], t[i + i + 1]);
  }
}
int query(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (tl == l && tr == r) return t[v];
  int tm = (tl + tr) >> 1;
  return max(query(v + v, tl, tm, l, min(r, tm)),
             query(v + v + 1, tm + 1, tr, max(tm + 1, l), r));
}
int getX(int v, int tl, int tr, int l, int y) {
  if (t[v] <= y) return INF;
  if (tr <= l) return INF;
  if (tl == tr) return tl;
  int mid = (tl + tr) >> 1;
  if (tl > l) {
    if (t[v + v] > y)
      return getX(v + v, tl, mid, l, y);
    else
      return getX(v + v + 1, mid + 1, tr, l, y);
  }
  return min(getX(v + v, tl, mid, l, y), getX(v + v + 1, mid + 1, tr, l, y));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  queries.resize(n);
  set<int> d;
  for (int i = 0; i < n; i++) {
    string type;
    cin >> type;
    if (type == "add")
      queries[i].first = 0;
    else if (type == "remove")
      queries[i].first = 1;
    else
      queries[i].first = 2;
    cin >> queries[i].second.first >> queries[i].second.second;
    queries[i].second.first, queries[i].second.second;
    d.insert(queries[i].second.first);
  }
  for (auto k : d) {
    order[k] = compressed.size();
    compressed.push_back(k);
  }
  build(compressed.size());
  vert.resize(compressed.size());
  for (auto q : queries) {
    if (q.first == 0) {
      vert[order[q.second.first]].insert(q.second.second);
      update(order[q.second.first]);
    } else if (q.first == 1) {
      vert[order[q.second.first]].erase(q.second.second);
      update(order[q.second.first]);
    } else {
      int ans = getX(1, 0, sz - 1, order[q.second.first], q.second.second);
      if (ans == INF)
        cout << "-1\n";
      else {
        int y = *vert[ans].upper_bound(q.second.second);
        cout << compressed[ans] << " " << y << "\n";
      }
    }
  }
  return 0;
}
