#include<bits/stdc++.h>
using namespace std;
#define file(filename) freopen(filename".in","r",stdin),freopen(filename".out","w",stdout)
#define endl "\n"
#define INF 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define m_p make_pair
#define pb push_back
#define rush(T) while(T--)
#define f1n for(long long i=1;i<=n;i++)
#define f1jn for(int j=1;j<=n;j++)
#define forcin for(int i=1;i<=n;i++) cin>>a[i];
#define forcout for(int i=1;i<=n;i++) cout<<a[i]<<' ';
#define _rep(a,b,s) for(int i=a;i<=b;i+=s)
#define mem(a,num) memset(a,num,sizeof(a))
#define cmp greater<int>()
#define CLOSE ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define __rep(a) for(int i=1;i<=a;i++)
ll T,n,x;
string s;
stack<ll> st;
signed main(){
cin>>T;
rush(T){
cin>>n;
for(long long i=1;i<=n;i++){
cin>>s;
if(s=="push"){
cin>>x;
st.push(x);
}if(s=="pop"){
if(st.empty()) cout<<"Empty"<<endl;
else st.pop();
}if(s=="query"){
if(st.empty()) cout<<"Anguei!\n";
else cout<<st.top()<<endl;
}if(s=="size"){
cout<<st.size()<<endl;
}
}while(!st.empty()) st.pop();
}
return 0;
}