#include<iostream>
#include<queue>
#include<string>
#include<cmath>
using namespace std;
struct complex
{
int shi;
int fu;
complex(int a, int b) :shi(a), fu(b) {}
friend bool operator <(complex a, complex b)
{
return pow(a.shi,2)+pow(a.fu,2) < pow(b.shi,2)+pow(b.fu,2);
}
};
int main()
{
int N;
scanf("%d", &N);
string str;
priority_queue<complex>q;
while (N--)
{
cin>>str;
if (str == "Pop")
{
if (q.empty() == false)
{
complex c = q.top();
q.pop();
printf("%d+i%d\n", c.shi, c.fu);
printf("SIZE = %d\n", q.size());
}
else
{
cout << "empty\n";
}
}
else if (str == "Insert")
{
int a, b;
scanf("%d+i%d", &a, &b);
q.push(complex(a, b));
printf("SIZE = %d\n", q.size());
}
}
}