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