#include<bits/stdc++.h>
using namespace std;
unsigned long long n,m;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
stack<long long int> s;
cin>>m;
for(int j=1;j<=m;j++){
string h;
cin>>h;
if(h=="push"){
unsigned long long x;
cin>>x;
s.push(x);
}
if(h=="query"){
if(s.empty()){
cout<<"Anguei!\n";
}
else cout<<s.top()<<"\n";
}
if(h=="size"){
cout<<s.size()<<"\n";
}
if(h=="pop"){
if(s.empty()){
cout<<"Empty\n";
}
else s.pop();
}
}
}
}