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