#include<bits/stdc++.h>
using namespace std;
int main(){
queue<int> a;
int n;
cin>>n;
for(;n != 0;n--){
int w=0,x=0;
cin>>w;
if(w == 1){
cin>>x;
a.push(x);
}
else if(w == 2){
if(a.empty()){
cout<<"ERR_CANNOT_POP"<<endl;
}
else {
a.pop();
}
}
else if(w == 3){
if(a.empty()){
cout<<"ERR_CANNOT_POP"<<endl;
}
else {
cout<<a.front()<<endl;
}
}
else if(w == 4){
cout<<a.size()<<endl;
}
}
return 0;
}