#include <iostream>
#include <string>
#include <stack>
#define IOS cin.tie(0) ; cout.tie(0) ; ios::sync_with_stdio(0);
using namespace std;
typedef unsigned long long ULL;
ULL n,op;
stack<ULL>zhan;
int main()
{
IOS;
cin >> n;
while ( n-- )
{
cin >> op ;
while ( op-- )
{
string ope;
cin >> ope;
if( ope == "push" )
{
ULL k;
cin >> k;
zhan.push(k);
}
else if( ope == "query" )
{
if( zhan.empty() ) cout << "Anguei!" << endl;
else cout << zhan.top() << endl ;
}
else if(ope == "pop" )
{
if( zhan.empty() ) cout << "Empty" << endl ;
else zhan.pop();
}
else
{
cout << zhan.size() << endl;
}
}
}
return 0;
}