#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
unsigned long long stk[N],tt;
int size(){
return tt;
}
void push(int a){
stk[++tt]=a;
}
void pop(){
if(!size()) printf("Empty\n");
else tt--;
}
void query(){
if(!size()) printf("Anguei!\n");
else printf("%llu\n",stk[tt]);
}
void init(){
tt=0;
memset(stk,0,sizeof(stk));
}//重置
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
for(int i=1;i<=n;i++){
char c[6];//通过第三个字符区别操作
scanf("%s",c);
if(c[2]=='s'){
unsigned long long x;
scanf("%llu",&x);
push(x);
}
else if(c[2]=='p'){
pop();
}
else if(c[2]=='e'){
query();
}
else if(c[2]=='z'){
printf("%d\n",size());
}
}
init();
}
return 0;
}
33分,求调qwq