#include<bits/stdc++.h>
using namespace std;
string s;
int t;
int main(){
scanf("%d",&t);
while(t--){
stack<unsigned long long>a;
int n;scanf("%d",&n);
while(n--){
cin>>s;
if(s=="push"){
int r;
scanf("%d",&r);
a.push(r);
}
else if(s=="pop"){
if(a.size()==0) printf("Empty\n");
else a.pop();
}
else if(s=="query"){
if(s.size()==0) printf("Anguei!\n");
else cout<<a.top()<<endl;
}
else if(s=="size") cout<<a.size()<<endl;
}
}
return 0;
}
求大佬调