#include <bits/stdc++.h>
using namespace std;
stack<int> s;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
while(!s.empty())
s.pop();
while (n--) {
string op;
cin >> op;
if (op == "push") {
int x;
cin >> x;
s.push(x);
}
if (op == "pop") {
if (s.empty())
printf("Empty\n");
else
s.pop();
}
if (op == "query") {
if (s.empty())
printf("Anguei!\n");
else
printf("%d\n", s.top());
}
if (op == "size") {
printf("%lu\n", s.size());
}
}
}
return 0;
}