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