#include <iostream>
#include <queue>
using namespace std;

struct Complex{
    int real;
    int imag;
    Complex(int r, int i):real(r), imag(i){}
    bool operator< (Complex c2) const {
        return real*real+imag*imag < c2.real*c2.real+c2.imag*c2.imag;
    }
};

priority_queue<Complex> q;

int main() {
    int n;
    while(cin >> n){
        while(n --){
            string op;
            cin >> op;
            if(op == "Pop"){
                if(q.empty())
                    cout << "empty" << endl;
                else{
                    cout << q.top().real << "+i" << q.top().imag << endl;
                    q.pop();
                    cout << "SIZE = " << q.size() << endl;
                }
            }else{//Insert
                int real, imag;
                scanf("%d+i%d", &real, &imag);
                q.push(Complex(real, imag));
                cout << "SIZE = " << q.size() << endl;
            }
        }
    }

    return 0;
}