using System;
public class a_b
{
private static void Main()
{
ulong n, top = 0, t;
ulong[] stack = new ulong[10000010];
string[] does= new string[3];
string way;
t=(ulong)int.Parse(Console.ReadLine());
for(ulong i = 1; i <= t; i++)
{
n=(ulong)int.Parse(Console.ReadLine());
for(ulong j = 1; j <= n; j++)
{
way = Console.ReadLine();
does = way.Split(" ");
if (does[0] == "push")
{
top++;
stack[top] = (ulong)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;
}
}
}