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