#include<iostream>
#include<queue>
using namespace std;
struct xy {
int a;
int b;
string str;
};
bool operator<(xy x1, xy x2) {
int t = x1.a * x1.a + x1.b * x1.b;
int h = x2.a * x2.a + x2.b * x2.b;
return t < h; //小于就发生交换,才为真
}
priority_queue<xy> q;
int main() {
int n;
cin >> n;
cin.get();
while (n--) {
string s;
getline(cin, s);
if (s == "Pop") {
if (q.empty()) {
cout << "empty" << endl;
continue;
} else {
xy h = q.top();
q.pop();
cout << h.str << endl;
cout << "SIZE = " << q.size() << endl;
continue;
}
}
int g = 0, j = 0, flag = 0, bj;
for (int i = 0; i < s.size(); i++) {
if (flag == 0 && s[i] >= '0' && s[i] <= '9') {
g = g * 10 + s[i] - '0';
}
if (s[i] == ' ')bj = i;
if (s[i] == '+')flag = 1;
if (flag == 1 && s[i] >= '0' && s[i] <= '9') {
j = j * 10 + s[i] - '0';
}
}
xy k;
k.a = g, k.b = j;
s.erase(0, bj + 1);
k.str = s;
q.push(k);
cout << "SIZE = " << q.size() << endl;
}
}