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