#include <bits/stdc++.h>
using namespace std;
unsigned long long topPos = 0, temp, _stack[114514];
string actionNameGetter(string);
void __init();
int main()
{
__init();
string action;
int dataGroups, dataCounts;
scanf("%d", &dataGroups);
for(int i = 1 ; i <= dataGroups ; ++i)
{
scanf("%d", &dataCounts);
__init();
for(int j = 1 ; j <= dataCounts ; ++j)
{
if(j == 1) cin.ignore();
getline(cin, action);
action = actionNameGetter(action);
if(action == "push") _stack[topPos++] = temp;
else if(action == "pop")
{
if(topPos == 0) printf("Empty\n");
else topPos--;
}
else if(action == "query")
{
if(topPos == 0) printf("Anguei!\n");
else printf("%llu\n", _stack[topPos - 1]);
}
else if(action == "size") printf("%llu\n", topPos);
}
}
return 0;
}
string actionNameGetter(string s)
{
temp = 0;
string result = "";
for(int i = 0 ; i < s.size() ; ++i)
{
if(s[i] >= '0' && s[i] <= '9')
temp = temp * 10 + (s[i] - '0');
else if(s[i] != ' ')
result += s[i];
else continue;
}
return result;
}
void __init()
{
memset(_stack, 0, sizeof(_stack));
topPos = 0;
return ;
}