#include<bits/stdc++.h>
using namespace std;
int main()
{
int t; cin >> t;
while (t--)
{
stack<unsigned long long> stk;
int n; cin >> n;
string s;
while (n-- && cin >> s)
{
if (s == "push") {
int x; cin >> x;
stk.push(x);
}
else if (s == "query")
{
cout << stk.top();
cout << '\n';
}
if (stk.empty() && s == "query") cout << "Anguei!" << '\n';
else if (s == "size")
{
cout << stk.size() << '\n';
}
else if (s == "pop")
{
stk.pop();
}
if (s.empty() && s == "pop")
{
cout << "Empty" << '\n';
}
}
}
return 0;
}