#include <bits/stdc++.h>
#define int long long
using namespace std;
int T, n;
signed main(){
cin.tie(0), cout.tie(0);
cin >> T;
while(T--){
cin >> n;
stack<int> stk;
while(n--){
string s;
cin >> s;
if(s == "push"){
int x;
cin >> x;
stk.push(x);
}
if(s == "query"){
if(s.empty()){
cout << "Anguei!" << endl;
} else {
cout << stk.top() << endl;
}
}
if(s == "pop"){
if(s.empty()){
cout << "Empty" << endl;
} else {
stk.pop();
}
}
if(s == "size"){
cout << s.size() << endl;
}
}
}
return 0;
}