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