#include<bits/stdc++.h>
#include<stack>
#define int unsigned long long
using namespace std;
stack<int> s;
signed main(){
int t;
cin>>t;
while(t--){
while(!s.empty()){
s.pop();
}
int n;
cin>>n;
for(int i=1;i<=n;i++){
string st;
cin>>st;
if(st[0]=='p'&&st[1]=='u'){
long long x;
cin>>x;
s.push(x);
}
if(st[0]=='q'&&st[1]=='u'){
if(!s.empty())cout<<s.top()<<endl;
else cout<<"Anguei!"<<endl;
}
if(st[0]=='s'&&st[1]=='i')cout<<s.size()<<endl;
if(st[0]=='p'&&st[1]=='o'){
if(!s.empty())s.pop();
else cout<<"Empty"<<endl;
}
}
}
return 0;
}
二三点WA,33分