#include <iostream>
#include <string>
using namespace std;
typedef unsigned long long ull;
const int N = 1e6+10;
int id;
ull st[N];
void push(int x)
{
st[++id]=x;
}
void query()
{
if(id==0)
{
cout << "Anguei!" << endl;
}
else
{
cout << st[id] << endl;
}
}
int size()
{
return id;
}
void pop()
{
if(id==0)
{
cout << "Empty" << endl;
}
else
{
id--;
}
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t;
cin >> t;
while(t--)
{
id = 0;
int n;
cin >> n;
for(int i=0;i<n;i++)
{
string op;
cin >> op;
if(op=="push")
{
ull x;
cin >> x;
push(x);
}
else if(op=="query")
{
query();
}
else if(op=="size")
{
cout << size() << endl;
}
else
{
pop();
}
}
}
return 0;
}