#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
stack<int> st;
signed main(){
int n;
cin>>n;
while(!st.empty()){st.pop();}
for(int i=1;i<=n;i++){
int cs;
cin>>cs;
for(int j=1;j<=cs;j++){
string cz;
int ps;
cin>>cz;
if(cz=="push")cin>>ps,st.push(ps);
if(cz=="query"){
if(st.empty())cout<<"Anguei!"<<endl;
else cout<<st.top()<<endl;
}
if(cz=="pop"){
if(st.empty())cout<<"Empty"<<endl;
else st.pop();
}
if(cz=="size")cout<<st.size()<<endl;
}
}
}