#include<bits/stdc++.h>
using namespace std;
stack<unsigned long long> s;
int t,n;
string bd;
void input()
{
cin>>t;
}
void calc()
{
for(int j=1;j<=t;j++)
{
scanf("%d\n", &n);
for(int i=1;i<=n;i++)
{
cin>>bd;
if(bd=="push")
{
unsigned long long x;
scanf("%llu\n", &x);
s.push(x);
}
else if(bd=="pop")
{
if(!s.empty())
s.pop();
else
printf("Empty\n");
}
else if(bd=="query")
{
if(!s.empty())
printf("%ull\n", s.top());
else
printf("Angue!\n");
}
else if(bd=="size")
{
printf("%d\n", s.size());
}
}
while(!s.empty())
s.pop();
}
}
int main()
{
input();
calc();
}