#include<bits/stdc++.h>
using namespace std;
stack <unsigned long long> st;
int main()
{
int T;
cin >> T;
while(T--)
{
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
string s;
cin >> s;
if(s == "push")
{
long long x;
cin >> x;
st.push(x);
}
if(s == "pop")
{
if(st.empty())
{
cout << "Empty\n";
continue;
}
st.pop();
}
if(s == "query")
{
if(st.empty())
{
cout << "Anguei!\n";
continue;
}
cout << st.top() << endl;
}
if(s == "size")
{
cout << st.size() << endl;
}
}
}
return 0
;
}