#include<bits/stdc++.h>
using namespace std;
long long s[1000001];
int T, top;
int main() {
scanf("%d", &T);
for (int i = 1; i <= T; i++) {
int n;
scanf("%d", &n);
for (int j = 1; j <= n; j++) {
char a[10];
scanf("%s", a + 1);
if (a[2] == 'u') {
long long x;
scanf("%lld", &x);
s[++top] = x;
}else
if (a[1] == 'p') {
if (top)
--top;
else
printf("Empty\n");
}else
if (a[1] == 'q') {
if (top)
printf("%d\n", s[top]);
else
printf("Anguei!\n");
}else
printf("%d\n", top);
}
}
}