#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2e5+10,inf=1e9+10;
const ll INF=1e18+10;
struct node{
int x;
node *pst;
};
int len=0;
node *head;
void push(int x){
node s={x,head};
head=&s;
len++;
return;
}
void pop(){
if(!len){
cout<<"Empty"<<'\n';
return;
}
head=head->pst;
len--;
return;
}
void query(){
if(!len){
cout<<"Anguei!"<<'\n';
return;
}
cout<<head->x<<'\n';
return;
}
void size(){
cout<<len<<'\n';
return;
}
void solve(){
node s;
head=&s;
int t;
cin>>t;
while(t--){
string op;
cin>>op;
if(op=="push"){
int x;
cin>>x;
push(x);
}
if(op=="pop")
pop();
if(op=="query")
query();
if(op=="size")
size();
}
return;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--)
solve();
return 0;
}