#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
stack<int>sta;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;cin >> t;
while(t--){
int n;cin >> n;
while (!sta.empty()) {
sta.pop();
}
for (int i = 1;i <= n;i++){
string cz;cin >> cz;
if (cz == "size") cout << sta.size() << "\n" ;
else if (cz == "pop"){
if (sta.empty()){
cout << "Empty" << "\n";
}
else sta.pop();
}
else if (cz == "push"){
long long x;cin >> x;
sta.push(x);
}
else if (cz == "query"){
if (sta.empty()){
cout << "Anguei!" << "\n";
}
else{
cout << sta.top() << "\n";
}
}
}
}
return 0;
}