#include<bits/stdc++.h>
using namespace std;
string s;
int t,n;
long long x,a[1000005],tot,top;
int main(){
cin>>t;
while(t--){
top=1;
tot=0;
cin>>n;
while(n--){
cin>>s;
if(s=="push"){
cin>>x;
++tot;
a[tot]=x;
}
else if(s=="pop"){
if(tot-top+1<=0)cout<<"Empty\n";
else top++;
}
else if(s=="query"){
if(tot-top+1<=0)cout<<"Anguei!\n";
else cout<<a[top]<<endl;
}
else if(s=="size")cout<<tot-top+1<<endl;
}
}
return 0;
}