#include<iostream>
#include<stack>
#include<string>
using namespace std;
unsigned long long a,b;
unsigned long long x;
string str;
stack<int>s;
int main(){
cin>>a;
for(unsigned long long i=1;i<=a;i++){
cin>>b;
for(unsigned long long j=1;j<=b;j++){
cin>>str;
if(str == "push"){
cin>>x;
s.push(x);
}
if(str == "query"){
if(s.empty()){
cout<<"Anguei!"<<endl;
}else{
cout<<s.top()<<endl;
}
}
if(str == "pop"){
if(s.empty()){
cout<<"Empty"<<endl;
}else{
s.pop();
}
}
if(str == "size"){
x=s.size();
cout<<x<<endl;
}
}
}
return 0;
}