#include<bits/stdc++.h>
using namespace std;
int t, n, x;
string s;
int main(){
cin >> t;
for(int i=0; i<t; i++){
cin >> n;
queue<unsigned long long> q;
for(int i=0; i<n; i++){
cin >> s;
if(s=="push"){
cin >> x;
q.push(x);
}
else if(s=="pop"){
if(q.empty()) cout << "Empty";
else q.pop();
}
else if(s=="query"){
if(q.empty()) cout << "Anguei!";
else cout << q.top();
}
else{
cout << q.size();
}
}
}
return 0;
}