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