#include<stack>
using namespace std;
string code;
int t,n,x;
stack <unsigned long long int> st;
int main()
{
cin >> t;
while(t--)
{
cin >> n;
for(int i=1;i<=n;i++)
{
cin >> code;
if(code=="push")
{
cin >> x;
st.push(x);
}
else if(code=="pop")
{
if(st.empty()) cout << "Empty" << endl;
else st.pop();
}
else if(code=="query")
{
if(st.empty()) cout << "Anguei!" << endl;
else cout << st.top() << endl;
}
else if(code=="size") cout << st.size() << endl;
}
}
return 0;
}