#include "cstdio"
#include "queue"
#include "string"
#include "iostream"

using namespace std;
struct Complex {
    int real;
    int imag;

};

bool operator<(Complex lhs, Complex rhs) {
    return lhs.real * lhs.real + lhs.imag * lhs.imag < rhs.real * rhs.real + rhs.imag * rhs.imag;
}

int main() {
    int n;
    scanf("%d", &n);
    priority_queue<Complex> pqueue;
    char action[30];
    for (int i = 0; i < n; ++i) {


//        scanf("%s", action);

//        string actionstr = action;
        string actionstr = "";
        cin>>actionstr;
        if (actionstr == "Pop") {
            if (pqueue.empty()) {
                printf("empty\n");
            } else {
                printf("%d+i%d\n", pqueue.top().real, pqueue.top().imag);
                pqueue.pop();
                printf("SIZE = %d\n", pqueue.size());
            }
        } else if (actionstr == "Insert") {
            int re, im;
            scanf("%d+i%d\n", &re, &im);
            Complex c;
            c.real = re;
            c.imag = im;
            pqueue.push(c);
            printf("SIZE = %d\n", pqueue.size());
        }
    }
}