#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
const ll N=1e7;
ll s[N],t,n,m,top=0;
string q;
void push()
{
cin>>m;
top++;
s[top]=m;
}
void pop()
{
if (top==0)
{
cout<<"Empty"<<endl;
return;
}
s[top]=0;
top--;
}
void query()
{
if (top==0)
{
cout<<"Anguei!"<<endl;
return;
}
cout<<s[top]<<endl;
}
void size()
{
cout<<top<<endl;
}
int main()
{
cin>>t;
while (t--)
{
cin>>n;
for (long long i=1;i<=n;i++)
{
cin>>q;
if (q=="push")
push();
if (q=="pop")
pop();
if (q=="query")
query();
if (q=="size")
size();
}
}
return 0;