#include <iostream>
using namespace std;
int stack[1000020], top;
int main() {
int T;
string str;
cin >> T;
for (int i = 0; i < T; i++) {
int n;
unsigned long long int x;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> str;
if (str == "push") {
cin >> x;
stack[top++] = x;
}
else if (str == "query") {
if (top == 0) {
cout << "Anguei!" << endl;
}
else {
cout << stack[top - 1] << endl;
}
}
else if (str == "size") {
cout << top << endl;
}
else if (str == "pop") {
if (top > 0) {
top--;
}
else {
cout << "Empty" << endl;
}
}
}
top = 0;
}
return 0;
}