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