#include <bits/stdc++.h>
using namespace std;
struct node {
    int a;
    int b;
};
bool operator<( node n1, node n2) {
    //n1的模小于n2的模,则交换
    return n1.a * n1.a + n1.b * n1.b < n2.a * n2.a + n2.b * n2.b;
}
int main() {
    int n;
    priority_queue<node> q;
    while (cin >> n) {
        for (int i = 0; i < n; i++) {
//          string s;
            char s1[30];
            cin >> s1;
            string s = s1;
            if (s == "Pop") {
                if (!q.empty()) {
                    cout << q.top().a << "+i" << q.top().b << endl;
                    q.pop();
                    cout << "SIZE = " << q.size() << endl;

                } else {
                    cout << "empty" << endl;
                }
            } else if (s == "Insert") {
                int a, b;
                scanf("%d+i%d", &a, &b);
                node c;
                c.a = a;
                c.b = b;
                q.push(c);
                cout << "SIZE = " << q.size() << endl;
            }
        }
    }
    return 0;
}