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