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