#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct Stack {
int p,a[100001];
Stack() : p(0) {}
void push(int x) {
a[p++] = x;
}
bool empty() {
return p==0;
}
void pop() {
if(p!=0)--p;
}
int top() {
return a[p - 1];
}
int size() {
return p;
}
} s;
string st;
ll n,t,a;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--) {
cin>>n;
while(!s.empty())s.pop();
while(n--) {
cin>>st;
if(st=="query") {
if(s.empty())cout<<"Anguei!"<<endl;
else cout<<s.top()<<endl;
}
if(st=="pop") {
if(s.empty())cout<<"Empty"<<endl;
else s.pop();
}
if(st=="size") {
cout<<s.size()<<endl;
}
if(st=="push") {
cin>>a;
s.push(a);
}
}
}
return 0;
}