#include<cstdio>
#include<cstring>
struct stack {
int *a, tot, now;
stack() {
tot = 1;
a = new int[1];
now = 0;
}
~stack() {
delete[] a;
a = nullptr;
}
void push(const int x) {
a[now++] = x;
if (now >= tot) {
int *p = a;
a = new int[tot << 1];
memcpy(a, p, now << 2);
delete[] p;
}
}
void pop() {
if (now == 0) {
printf("Empty\n");
return;
}
now--;
if (now <= (tot >> 2)) {
int *p = a;
a = new int[tot >> 1];
memcpy(a, p, now);
delete[] p;
}
}
void query() {
if (now == 0) {
printf("Anguei!\n");
return;
}
printf("%d\n", a[now - 1]);
}
void size() {
printf("%d\n", now);
}
};
int main() {
int t;
scanf("%d", &t);
while (t--) {
stack s;
char c[10];
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%s", c);
if (c[0] == 'q') {
s.query();
} else if (c[0] == 's') {
s.size();
} else if (c[1] == 'o') {
s.pop();
} else {
int x;
scanf("%d", &x);
s.push(x);
}
}
}
return 0;
}