#include <stdio.h>
#include <stdlib.h>
typedef int datatype;
typedef struct Node{
datatype data;
struct Node * next;
}Node;
typedef struct Stack{
Node * Top;
int size;
}Stack;
void Start(Stack * stack){
stack->Top = (Node *)malloc(sizeof(Node));
stack->Top = NULL;
stack->size = 0;
}
void push(Stack * stack, datatype data){
Node * node = (Node *)malloc(sizeof(Node));
node->data = data;
node->next = stack->Top;
stack->Top = node;
stack->size ++;
}
void pop(Stack * stack){
if(isEmpty(stack)){
printf("Empty\n");
}
else{
stack->Top = stack->Top->next;
stack->size --;
}
}
void query(Stack * stack){
if(isEmpty(stack)){
printf("Anguei!\n");
}
else{
printf("%d\n", stack->Top->data);
}
}
int isEmpty(Stack * stack){
int count;
if(stack->size == 0){
count = 1;
}
else{
count = 0;
}
return count;
}
void size(Stack * stack){
printf("%d\n", stack->size);
}
void clearStack(Stack* stack) {
while (!isEmpty(stack)) {
pop(stack);
}
}
int main(){
Stack stack;
Start(&stack);
int T;
scanf("%d", &T);
int i, j, k = 0;
for(i = 0; i < T; i ++){
int n;
scanf("%d", &n);
for(j = 0; j < n; j ++){
char str[10];
scanf("\n%[^\n]", str);
char ch1 = str[0];
char ch2 = str[1];
if(ch1 == 'p'){
if(ch2 == 'u'){
push(&stack, str[5] - '0');
}
else{
pop(&stack);
}
}
else if(ch1 == 'q'){
query(&stack);
}
else{
size(&stack);
}
}
clearStack(&stack);
}
return 0;
}