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