#include<iostream>
#include<stack>
using namespace std;
#define ll unsigned long long
ll T;
int main()
{
cin>>T;
while(T--)
{
stack<ll> st;
ll n;
cin>>n;
string s;
int m;
for(ll i=1;i<=n;i++)
{
cin>>s;
if(s=="push")
{
cin>>m;
st.push(m);
}
else if(s=="query")
{
if(st.empty())
{
cout<<"Anguei!"<<endl;
}
else
{
cout<<st.top()<<endl;
}
}
else if(s=="pop")
{
if(st.empty())
{
cout<<"Empty"<<endl;
}
else
{
st.pop();
}
}
else if(s=="size")
{
cout<<st.size()<<endl;
}
}
while(st.size()!=0)
{
st.pop();
}
}
return 0;
}