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