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