#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
const ll N = 1e5 + 5, p1 = 911382323, p2 = 972663749, mod = 1e9 + 123;
struct treap {
  pair<int, int> pt;
  int y, mxY;
  treap *left, *right;
  treap(pair<int, int> A) {
    pt = A;
    mxY = A.second;
    y = (rand() << 16) | rand();
    left = nullptr;
    right = nullptr;
  }
};
treap *root = nullptr;
int get_mxY(treap *v) { return v == nullptr ? -INT_MAX : v->mxY; }
void update(treap *v) {
  if (v == nullptr) {
    return;
  }
  v->mxY = max(v->pt.second, max(get_mxY(v->left), get_mxY(v->right)));
}
treap *merge(treap *t1, treap *t2) {
  if (t1 == nullptr) {
    return t2;
  }
  if (t2 == nullptr) {
    return t1;
  }
  if (t1->y < t2->y) {
    t2->left = merge(t1, t2->left);
    update(t2);
    return t2;
  } else {
    t1->right = merge(t1->right, t2);
    update(t1);
    return t1;
  }
}
pair<treap *, treap *> split(treap *v, pair<int, int> k) {
  pair<treap *, treap *> res;
  if (v == nullptr) {
    return make_pair(v, v);
  }
  if (k.first < v->pt.first) {
    pair<treap *, treap *> temp = split(v->left, k);
    v->left = temp.second;
    update(v);
    res = make_pair(temp.first, v);
  } else if (k.first > v->pt.first) {
    pair<treap *, treap *> temp = split(v->right, k);
    v->right = temp.first;
    update(v);
    res = make_pair(v, temp.second);
  } else if (k.first == v->pt.first) {
    if (k.second == v->pt.second) {
      pair<treap *, treap *> temp = split(v->left, k);
      v->left = temp.second;
      update(v);
      res = make_pair(temp.first, v);
    } else if (k.second < v->pt.second) {
      pair<treap *, treap *> temp = split(v->left, k);
      v->left = temp.second;
      update(v);
      res = make_pair(temp.first, v);
    } else {
      pair<treap *, treap *> temp = split(v->right, k);
      v->right = temp.first;
      update(v);
      res = make_pair(v, temp.second);
    }
  }
  return res;
}
void print(treap *v) {
  if (v == nullptr) {
    return;
  }
  print(v->left);
  cout << "{" << v->pt.first << ", " << v->pt.second << "} ";
  print(v->right);
}
void add(pair<int, int> k) {
  pair<treap *, treap *> temp = split(root, k);
  root = merge(temp.first, merge(new treap(k), temp.second));
}
void remove(pair<int, int> k) {
  treap *seg1, *seg2, *seg3;
  pair<treap *, treap *> temp = split(root, k);
  seg1 = temp.first;
  temp = split(temp.second, make_pair(k.first, k.second + 1));
  seg2 = temp.first;
  seg3 = temp.second;
  root = merge(seg1, seg3);
}
pair<int, int> find(treap *v, pair<int, int> k) {
  if (v == nullptr) {
    return make_pair(-1, -1);
  }
  if (get_mxY(v->left) > k.second) {
    return find(v->left, k);
  } else if (v->pt.second > k.second) {
    return v->pt;
  } else if (get_mxY(v->right) > k.second) {
    return find(v->right, k);
  } else {
    return make_pair(-1, -1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    string second;
    cin >> second;
    int x, y;
    cin >> x >> y;
    if (second == "add") {
      add(make_pair(x, y));
    } else if (second == "remove") {
      remove(make_pair(x, y));
    } else {
      pair<treap *, treap *> temp = split(root, make_pair(x + 1, -1));
      pair<int, int> res = find(temp.second, make_pair(x, y));
      res.first == -1 ? cout << "-1\n"
                      : cout << res.first << " " << res.second << "\n";
      root = merge(temp.first, temp.second);
    }
  }
  return 0;
}
