#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct complex{
    int real;
    int fake;
};

bool compare(complex a, complex b)  //比较模的平方
{
    int num1=a.real*a.real+a.fake*a.fake;
    int num2=b.real*b.real+b.fake*b.fake;
    return num1<num2;
}

int main() {
    int n;
    while (cin >> n) {
        vector<complex> mystring;
        while(n--)
        {
            string s;
            cin >> s;
            if(s=="Pop")
            {
                if(mystring.empty())
                {
                    cout << "empty" << endl;
                }
                else{
                    sort(mystring.begin(),mystring.end(),compare);
                    cout << mystring.back().real << "+i" << mystring.back().fake << endl;
                    mystring.pop_back();
                    cout << "SIZE = " << mystring.size() << endl; 
                }
            }
            else{
                complex s1;
                int a,b;
                scanf("%d+i%d", &a,&b);  //若s为Insert,则继续输入
                s1.real=a;
                s1.fake=b;
                mystring.push_back(s1);
                cout << "SIZE = " << mystring.size() << endl; 
            }
        }
    }
}