#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
struct fushu{
int x;
int y;
int sum;
};
bool cmp(fushu a, fushu b){
if(a.sum != b.sum) return a.sum > b.sum;
else return a.y < b.y;
}
int main(){
int n, size = 0;
cin >> n;
getchar();
vector<fushu> fs;
for(int i = 0; i < n; i++){
string instruction;
getline(cin, instruction);
if(instruction == "Pop"){
if(fs.size() == 0) printf("empty\n");
else{
if(fs[0].y > 0) cout << fs[0].x << "+i" << fs[0].y << endl;
else cout << fs[0].x << "-i" << abs(fs[0].y) << endl;
fs.erase(fs.begin(), fs.begin() + 1);
size--;
cout << "SIZE = " << fs.size() << endl;
}
}else{
fushu tmp;
int pos;
for(int j = 7; j < instruction.length(); j++){
if(instruction[j] == '+' || instruction[j] == '-'){
pos = j;
break;
}
}
tmp.x = stoi(instruction.substr(7, pos - 7));
if(instruction[pos] == '+') tmp.y = stoi(instruction.substr(pos + 2, instruction.length() - pos));
else tmp.y = -stoi(instruction.substr(pos + 2, instruction.length() - pos));
tmp.sum = pow(tmp.x, 2) + pow(tmp.y, 2);
fs.push_back(tmp);
sort(fs.begin(), fs.end(), cmp);
size++;
cout << "SIZE = " << fs.size() << endl;
}
// cout << "SIZE = " << fs.size() << endl;
}
return 0;
}