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