#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2, inf = 1e9 + 1;
vector<pair<char, pair<int, int> > > q;
vector<int> vec;
int n;
set<pair<int, int> > fen[N + 10];
void compress() {
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
}
void add(int val, int p) {
  int y = p;
  p = n - p;
  for (; p <= n; p += p & -p) fen[p].insert({val, y});
}
void del(int val, int p) {
  int y = p;
  p = n - p;
  for (; p <= n; p += p & -p) fen[p].erase({val, y});
}
pair<int, int> get(int val, int p) {
  pair<int, int> rtr = {inf, inf};
  p = n - p;
  for (; p > 0; p -= p & -p) {
    auto it = fen[p].lower_bound(make_pair(val, -1));
    if (it != fen[p].end()) rtr = min(rtr, *(it));
  }
  return rtr;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    int x, y;
    cin >> s >> x >> y;
    q.push_back({s[0], {x, y}});
    vec.push_back(y);
  }
  compress();
  for (int i = 0; i < n; i++) {
    if (q[i].first == 'a') {
      int x =
          lower_bound(vec.begin(), vec.end(), q[i].second.second) - vec.begin();
      add(q[i].second.first, x);
    }
    if (q[i].first == 'r') {
      int x =
          lower_bound(vec.begin(), vec.end(), q[i].second.second) - vec.begin();
      del(q[i].second.first, x);
    }
    if (q[i].first == 'f') {
      int x = lower_bound(vec.begin(), vec.end(), q[i].second.second) -
              vec.begin() + 1;
      pair<int, int> rtr = get(q[i].second.first + 1, x);
      if (rtr == make_pair(inf, inf)) {
        cout << -1 << "\n";
      } else
        cout << rtr.first << " " << vec[rtr.second] << "\n";
    }
  }
  return 0;
}
