#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<unsigned long long> v;
int t;
cin>>t;
string caozuo;
unsigned long long temp;
while(t--)
{
int n;
cin>>n;
for(int i=0;i<n;++i)
{
cin>>caozuo;
if(caozuo=="push")
{
cin>>temp;
v.push_back(temp);
}
if(caozuo=="pop")
{
if(v.size()!=0)
v.pop_back();
else
cout<<"Empty"<<endl;
}
if(caozuo=="query")
{
if(v.size()!=0)
cout<<v.back()<<endl;
else
cout<<"Anguei!"<<endl;
}
if(caozuo=="size")
{
cout<<v.size()<<endl;
}
}
}
}