#include<iostream>
#include<string>
#define maxn (int)(1e6)
typedef unsigned long long ull;
using namespace std;
int top=-1,T,n;
ull s[maxn]={},x;
string op;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>T;
while(T--)
{
cin>>n;
while(n--)
{
cin>>op;
if(op=="push")
{
cin>>x;
s[++top]=x;
}
else if(op=="pop")
{
if(top==-1)
cout<<"Empty"<<endl;
else
top--;
}
else if(op=="query")
{
if(top==-1)
cout<<"Anguei!"<<endl;
else
cout<<s[top]<<endl;
}
else if(op=="size")
cout<<top+1<<endl;
}
top=-1;
}
return 0;
}