using System;
public class a_b
{
private static void Main()
{
long n, top = 0, t;
long[] stack = new long[1000010];
string[] does= new string[3];
string way;
t=int.Parse(Console.ReadLine());
for(int i = 1; i <= t; i++)
{
n=int.Parse(Console.ReadLine());
for(int j = 1; j <= n; j++)
{
way = Console.ReadLine();
does = way.Split(" ");
if (does[0] == "push")
{
top++;
stack[top] = int.Parse(does[1]);
}
else if (does[0] == "pop")
{
if (top == 0)
{
Console.WriteLine("Empty");
}
else
{
top--;
}
}
else if (does[0] == "size")
{
Console.WriteLine(top);
}
else
{
if(top == 0)
{
Console.WriteLine("Anguei!");
}
else
{
Console.WriteLine(stack[top]);
}
}
}
top = 0;
}
}
}