import java.util.*;
import java.io.*;
public class Main{
public static void main(String args[]){
long t,n,x;
long top=0;
long[] stack=new long[10000000];
String w;
Scanner in=new Scanner(System.in);
t=in.nextInt();
for(long i=1;i<=t;i++){
n=in.nextInt();
for(long j=1;j<=n;j++){
w=in.next();
if(w.equals("push")==true){
top++;
x=in.nextInt();
stack[(int)top]=x;
}else if(w.equals("pop")==true){
if(top==0){
System.out.println("Empty");
}else{
top--;
}
}else if(w.equals("query")==true){
if(top==0){
System.out.println("Anguei!");
}else{
System.out.println(stack[(int)top]);
}
}else{
System.out.println(top);
}
}
top=0;
}
}
}