#include<bits/stdc++.h>
using namespace std;
typedef long long inr;
typedef unsigned long long unr;
#define fur(y) for(inr i=1;i<=y;i++)
#define fru(i,s,e) for(inr i=s;i<=e;i++)
#define frd(i,s,e) for(inr i=s;i>=e;i--)
#define el <<endl
#define sp <<" "<<
inr n,m,k,h,r,x,z,y,T,sum=0,ans=0,c;
int main() {
ios::sync_with_stdio(false);
cin>>T;
while(T--) {
cin>>n;
stack<int> s;
for(int i=1; i<=n; i++) {
string str;
cin>>str;
if(str=="push") {
cin>>x;
s.push(x);
} else if(str=="query") {
if(!s.empty()) cout<<s.top()<<endl;
else cout<<"Anguei!"<<endl;
} else if(str=="size") {
cout<<s.size()<<endl;
} else {
if(!s.empty()) s.pop();
else cout<<"Empty"<<endl;
}
}
}
return 0;
}