/*
scanf("%d+i%d",&s,&x);//巧用scanf接受含有数字的字符串
优先队列默认从大到小排序
*/
#include <iostream>
#include <queue>
using namespace std;
struct Complex
{
int a;
int b;
bool operator<(Complex c) const{
if(a*a+b*b==c.a*c.a+c.b*c.b)
return b>c.b;//模相等则虚部从小到大排
else
{
return a*a+b*b<c.a*c.a+c.b*c.b;//模不等则模从大到小排
}
}
};
int main()
{
int n;
while(cin>>n)
{
priority_queue<Complex> q;
for(int i=1;i<=n;i++)
{
string tmp;cin>>tmp;
if(tmp=="Pop")
{
if(q.empty())cout<<"empty"<<endl;
else
{
Complex t=q.top();
q.pop();
cout<<t.a<<"+i"<<t.b<<endl;
cout<<"SIZE = "<<q.size()<<endl;
}
}
else {
int s,x;
scanf("%d+i%d",&s,&x);//巧用scanf接受含有数字的字符串
Complex t;
t.a=s;t.b=x;
//int jia;
//jia=str.find('+');
//t.a=str.substr(0,jia)-'0;//子串开始索引,子串长度
//t.b=str.substr(jia+2)-'0';
q.push(t);
cout<<"SIZE = "<<q.size()<<endl;
}
}
}
}