#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<stack>
using namespace std;
stack<int> nums;
string command;
int num;
void clearStack(stack<int>& s) {
while (!s.empty()) {
s.pop();
}
}
int main(void) {
int T, n;
cin >> T;
while (T--) {
cin >> n;
while (n--) {
cin >> command;
if (command == "push") {
cin >> num;
nums.push(num);
}
else if (command == "pop") {
if (!nums.empty()) {
nums.pop();
}
else {
cout << "Empty" << endl;
}
}
else if (command == "query") {
if (!nums.empty()) {
cout << nums.top() << endl;
}
else {
cout << "Anguei!" << endl;
}
}
else if (command == "size") {
cout << nums.size() << endl;
}
}
clearStack(nums);
}
return 0;
}