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