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