#include <iostream>
#include <set>
using namespace std;
int n;
set<int> length;
int op, len;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
while (n--) {
cin >> op >> len;
if (op == 1) {
auto pos = length.find(len);
if (pos != length.end())
cout << "Already Exist" << endl;
else length.insert(len);
}
else if (op == 2) {
if (length.empty()) cout << "Empty" << endl;
else {
auto pos = length.find(len);
if (pos != length.end()) {
cout << len << endl;
length.erase(pos);
}
else {
bool haveLess = false;
int out;
bool a = false;
for (auto elem : length) {
if (elem < len) {
haveLess = true;
out = elem;
}
else if (elem > len) {
if (haveLess) {
cout << out << endl;
length.erase(out);
a = true;
break;
}
else {
cout << elem << endl;
length.erase(elem);
a = true;
break;
}
}
}
if (!a) {
cout << out << endl;
length.erase(out);
}
}
}
}
}
return 0;
}