#include <iostream>
#include <stack>
using namespace std;
int main(){
string str;
int p;
long long t;
stack<int>s;
cin >> t;
long long tt;
for(int i = 1;i <= t;i++){
cin >> tt;
for(int j = 1;j <= tt;j++){
cin >> str;
if(str=="push"){
cin >> p;
s.push(p);
}
else if(str=="query"){
if(s.size())cout << s.top()<<endl;
else cout << "Anguei!"<<endl;
}
else if(str=="pop"){
if(s.size())s.pop();
else cout << "Empty"<<endl;
}
else if(str=="size"){
cout << s.size()<<endl;
}
}
}
}