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