#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s1,s2;
int st[1000000+5];
int top=0;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
while(n--)
{
string opt;
cin>>opt;
if(opt=="push")
{
int x;
cin>>x;
top++;
st[top]=x;
}
else if(opt=="pop")
{
if(top==0){
cout<<"Empty\n";
continue;
}
st[top]=0;
top--;
}
else if(opt=="query")
{
if(top==0)
{
cout<<"Anguei!\n";
continue;
}
cout<<st[top]<<endl;
}
else if(opt=="size")
{
cout<<top<<endl;
}
}
}
return 0;
}