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