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