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