#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
struct fushu{
    int x; //实部
    int y; //虚部
    int z; //是否被删除
};
int main(){
    int n,m=0,SIZE,max=-1,count,sum;
    char op[1000];
    scanf("%d",&n);
    struct fushu nums[n];
    for(int i=0;i<n;i++){
        nums[i].z=0;
    }
    for(int k=0;k<=n;k++){
        cin.getline(op,1000);
        if(op[0]=='I'){
            int nums1[50],nums2[50],b=0,a,c,d=0,sum1=0,sum2=0,g=1,h=1;
            for(a=7;op[a]!='+';a++){
                nums1[b]=op[a]-'0';
                b++;
            }
            for(c=a+2;op[c]!='\0';c++){
                nums2[d]=op[c]-'0';
                d++;
            }
            for(int e=b-1;e>=0;e--){
                sum1=nums1[e]*g+sum1;
                g=g*10;
            }
            for(int f=d-1;f>=0;f--){
                sum2=nums2[f]*h+sum2;
                h=h*10;
            }
            nums[m].x=sum1;
            nums[m].y=sum2;
            nums[m].z=1;
            m++;
            SIZE=0;
            for(int j=0;j<n;j++){
                if(nums[j].z==1) SIZE++;
            }
            printf("SIZE = %d\n",SIZE);
            SIZE=0;
        }
        if(op[0]=='P'){
            SIZE=0;
            for(int j=0;j<n;j++){
                if(nums[j].z==1) SIZE++;
            }
            if(SIZE==0){
                printf("empty\n");
                SIZE=0;
            }
            else{
                for(int t=0;t<n;t++){
                    if(nums[t].z==1){
                        sum=nums[t].x*nums[t].x+nums[t].y*nums[t].y;
                        if(sum>max){
                            count=t;
                            max=sum;
                        }
                    }
                }
                printf("%d+i%d\n",nums[count].x,nums[count].y);
                nums[count].z=0;
                max=-1;
                printf("SIZE = %d\n",SIZE-1);
            }
        }
    }
    return 0;
}