#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
int t;cin>>t;
while(t--){
int n;cin>>n;
stack<ll>cl;
for(int i=1;i<=n;i++){
string x;cin>>x;
if(x=="push"){
ll y;cin>>y;
cl.push(y);
}
if(x=="query"){
if(cl.empty()){
cout<<"Anguei!"<<'\n';
}
else{
cout<<cl.top()<<'\n';
}
}
if(x=="pop"){
if(cl.empty()){
cout<<"Empty"<<'\n';
}
else{
cl.pop();
}
}
if(x=="size"){
cout<<cl.size()<<'\n';
}
}
}
}