#include <bits/stdc++.h>
using namespace std;
#define int long long
queue<int> q;
void solve(){
int choose;cin>>choose;
if(choose == 1){
int a;cin>>a;
q.push(a);
}else if(choose == 2){
if(q.empty()){
cout << "ERR_CANNOT_POP" << endl;
}else{
q.pop();
}
}else if(choose == 3){
if(q.size()){
cout << q.front() << endl;
}else{
cout << "ERR_CANNOT_POP" << endl;
}
}else if(choose == 4){
cout << q.size() << endl;
}
}
signed main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;cin>>n;
while(n--){
solve();
}
return 0;
}