#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct Node
{
int c0;
int c1;
int m;
}com[1001];
bool cmp(Node a,Node b)
{
if (a.m!=b.m) return a.m>b.m;//是大于号和小于号
else return a.c1<b.c1;//不是前面用的减号
}
int main()
{
int n;
int size;
while(scanf("%d",&n)!=EOF)
{
size=0;
int i;
while(n--)
{
char str[100];
scanf("%s",str);
if(str[0]=='P')
{
if(size==0)
printf("empty\n");
else
{
sort(com,com+size,cmp);
printf("%d+i%d\n",com[0].c0,com[0].c1);
for(i=0;i<size-1;i++) com[i]=com[i+1];
size--;
printf("SIZE = %d\n",size);//这里有空格
}
}
else if(str[0]=='I')
{
scanf("%d+i%d",&com[size].c0,&com[size].c1);
com[size].m=com[size].c0*com[size].c0+com[size].c1*com[size].c1;
size++;
printf("SIZE = %d\n",size);
}
}
}
return 0;
}