#include <iostream>
#include <stdio.h>
#include <stack>
using namespace std;
int main(){
int t,x;
cin>>t;
while(t--){
stack < int > s;
string h;
cin>>h;
if(h=="push"){
cin>>x;
s.push(x);
}
else if(h=="pop"){
if(s.size()==0)
cout<<"Empty"<<endl;
else cout<<s.pop()<<endl;
}
else if(h=="query"){
if(s.size()==0)
cout<<"Anguei"<<endl;
else cout<<s.top<<endl;}
else if(h=="size"){
cout<<s.size()<<endl;
}
}
return 0;
}