#include<iostream>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<string>
#include<algorithm>
#include <cstdlib>
#include<stdlib.h>
#include<sstream>
using namespace std;
unsigned long long a[1000007];
int main()
{
long t;
cin >> t;
long n;
string s;
int top=-1;
int count=0;
for (int i = 0; i < t; i++)
{
cin >> n;
for (int j = 0; j < n; j++)
{
cin >> s;
if (s == "push")
{
top++;
cin >> a[top];
count++;
}
else if (s == "pop")
{
if (count > 0)
{
a[top] = 0;
top--;
count--;
}
else
{
cout << "Empty" << "\n";
}
}
else if (s == "query")
{
if (count > 0)
{
cout << a[top]<<"\n";
}
else
{
cout << "Anguei!" << "\n";
}
}
else if (s == "size")
{
cout << count<<"\n";
}
}
}
return 0;
}