#include<iostream>
#include<stack>
#include<string>
using namespace std;
long long n,m,c;
int main(){
cin >> n;
for(long long i = 1; i <= n; i++){
cin >> m;
stack<int> s;
string op;
for(long long j = 1; j <= m; j++){
cin >> op;
if(op == "push"){
cin >> c;
s.push(c);
} else if(op == "query"){
if(s.empty() == true) cout << "Anguei!" << endl;
else cout << s.top() << endl;
} else if(op == "pop"){
if(s.empty() == true) cout << "Empty" << endl;
else s.pop();
} else if(op == "size") cout << s.size() << endl;
}
}
return 0;
}