#include <iostream>
#include <cstdio>
#include <queue>
#include <string>
using namespace std;
struct complex {
    int real;
    int imag;
  //构造函数初始化
  //在类的内部 ,名字和类名一样 ,没有放回值
    complex(int a, int b) :real(a), imag(b) {} 
};
//自定义 < 运算符
//运算符重载
//重载 < 原来的小于号 有两个参数 放回值是bool
//自定义一个函数 参数数量不变 返回值类型不变 名字是operator 运算符
//若a<b 返回true 大根堆
//若a<b 返回false 小根堆
bool operator < (complex lhs, complex rhs) {
    if (lhs.real * lhs.real + lhs.imag * lhs.imag < rhs.real * rhs.real + rhs.imag *rhs.imag) {
        return true;
    }
    else if(lhs.real * lhs.real + lhs.imag * lhs.imag == rhs.real * rhs.real + rhs.imag *rhs.imag&&lhs.imag<rhs.imag){
        return true;
    }
    else {
        return false;
    }
}

int main() {
    int n;
    scanf("%d", &n);
    priority_queue<complex> pqueue;
    for (int i= 0; i < n; i++) {
        // char actionarr[30];
        // scanf
        string str;
        cin >> str;
        if (str == "Pop") {
            if (pqueue.empty()) {
                printf("empty\n");
            }
            else {
                complex cur = pqueue.top();
                pqueue.pop();
                printf("%d+i%d\n", cur.real, cur.imag);
                printf("SIZE = %d\n", pqueue.size());
            }
        }
        else {
            int a, b;
            scanf("%d+i%d", &a, &b);
            pqueue.push(complex(a, b));
            printf("SIZE = %d\n", pqueue.size());
        }
    }

    return 0;
}