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