//KY195 复数集合
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
int n;
struct E{
    int a, b;
    bool operator<(const E &x)const{
        if(a*a+b*b==x.a*x.a+x.b*x.b) return b>x.b;
        return a*a+b*b<x.a*x.a+x.b*x.b;
    }
};
int main()
{
    while(cin>>n){
        priority_queue<E>q;
        for(int i=1;i<=n;i++){
            string s;
            cin>>s;
            if(s=="Pop"){
                if(q.size()){
                    auto t=q.top();
                    q.pop();
                    cout<<t.a<<"+i"<<t.b<<"\n";
                    cout<<"SIZE = "<<q.size()<<"\n";
                }else cout<<"empty\n";
            }else{
                string res;
                cin>>res;
                int pos=res.find('+');
                int a=0, b=0;
                for(int i=0;i<pos;i++) a=a*10+res[i]-'0';
                for(int i=pos+2;i<res.size();i++) b=b*10+res[i]-'0';
                q.push({a,b});
                cout<<"SIZE = "<<q.size()<<"\n";
            }
        }
    }
    return 0;
}