#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 1e6 + 10;
int t,n;
vector<unsigned long long int> stack;
void push(unsigned long long int x){
stack.push_back(x);
}
void pop(){
if(stack.size() == 0){
cout << "Empty" << endl;
return ;
}
stack.pop_back();
}
void query(){
if(stack.size() == 0){
cout << "Anguei!" << endl;
return ;
}
cout << stack[stack.size() - 1] << endl;
}
void size(){
cout << stack.size() << endl;
return ;
}
void check(string op){
if(op.size() == 5){
query();
}
else if(op.size() == 4){
if(op[0] == 'p'){
unsigned long long int x;
cin >> x;
push(x);
}
else {
size();
}
}
else if(op.size() == 3){
pop();
}
}
int main(){
cin >> t;
for(int i = 0;i < t;i++){
scanf("%d",&n);
for(int j = 0;j < n;j++){
string op;
cin >> op;
check(op);
}
}
return 0;
}