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