#include <iostream>
#include <stack>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
stack<unsigned long long> mys;
unsigned long long n, m, a;
string opr;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> m;
for (int j = 0; j < m; j++)
{
cin >> opr;
if (opr == "push")
{
cin >> a;
mys.push(a);
}
else if (opr == "pop")
{
if (mys.empty())
cout << "Empty" << endl;
else mys.pop();
}
else if (opr == "query")
{
if (mys.empty())
cout << "Anguei!" << endl;
else cout << mys.top() << endl;
}
else cout << mys.size() << endl;
}
}
return 0;
}