#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main(){
stack<ull> st;
ull b;
int T,n;
string tmp;
cin>>T;
for(int i=1;i<=T;i++){
cin>>n;
for(int i=1;i<=n;i++){
cin>>tmp;
if(tmp=="push"){
cin>>b;
st.push(b);
}
if(tmp=="pop"){
if(st.empty) cout<<"Empty"<<endl;
else st.pop;
}
if(tmp=="query"){
if(st.empty) cout<<"Anguei!"<<endl;
else cout<<st.top()<<endl;
}
if(tmp=="size") cout<<st.size()<<endl;
}
}
return 0;
}