#include<bits/stdc++.h>
using namespace std;
int a[114514],t,n,top;
string way;
void push(unsigned long long x);
int main(){
cin>>t;
for(int i=1;i<=t;i++){
cin>>n;
for(int j=1;j<=n;j++){
cin>>way;
if(way=="push"){
unsigned long long m;
cin>>m;
push(m);
}
if(way=="pop"){
if(!top){
cout<<"Empty"<<endl;
}else{
--top;
}
}
if(way=="size"){
cout<<top<<endl;
}
if(way=="query"){
if(!top){
cout<<"Anguei!"<<endl;
}else{
cout<<a[top]<<endl;
}
}
}
}
return 0;
}
void push(unsigned long long x){
a[++top]=x;
}