#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main() {
	vector<string> v;
	string cmd;
	int n;
	cin>>n;
	
	while(n--){
		cin>>cmd;
		if(cmd == "Pop"){
			if(v.empty()){
				cout<<"empty"<<endl;
			}else{
				int k = 0;	//记录最大值的下标
				int maxS = 0;	//记录最大值 
				for(int i = 0; i < v.size(); i++){
//					cout<<v[i].substr(0,v[i].find('+'))<<endl;
					string a = v[i].substr(0,v[i].find('+'));
					int shi = stoi(a);	//将字符串数字转为数字型 
//					cout<<shi<<endl;
					a =v[i].substr(v[i].find('i')+1); 
					int xu = stoi(a);
//					cout<<xu<<endl;
					if(pow(shi,2) + pow(xu,2) > maxS){
						k = i;
						maxS = pow(shi,2) + pow(xu,2);
					}	
				}
				cout<<v[k]<<endl;
				v.erase(v.begin()+k);
				cout<<"SIZE = "<<v.size()<<endl;
			}
		}else{
			string tmp;
			cin>>tmp;
			v.push_back(tmp);
			cout<<"SIZE = "<<v.size()<<endl;
		}
	}
}