#include <bits/stdc++.h>
using namespace std ;
int main ( )
{
int t ;
cin >> t ;
for ( int i = 1 ; i <= t ; ++i )
{
int n ;
cin >> n ;
queue <int> q ;
for ( int j = 1 ; j <= n ; ++j )
{
string s ;
cin >> s ;
if ( s[0] == 'p' && s[1] == 'u' )
{
int x ;
cin >> x ;
q.push ( x ) ;
}
else if ( s[0] == 'p' && s[1] == 'o' )
{
if ( q.empty ( ) )
{
cout << "Empty\n" ;
}
else q.pop ( ) ;
}
else if ( s[0] == 'q' )
{
if ( q.empty ( ) )
{
cout << "Anguei!" << endl ;
}
else
{
int sb ;
sb = q.front ( ) ;
cout << sb << endl ;
}
}
else if ( s[0] == 's' )
{
cout << q.size ( ) << "\n" ;
}
}
}
return 0 ;
}