#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    queue<int> q;
    while (t--)
    {
        int n;
        cin >> n;
        if(n==1){
            int x;
            cin >> x;
            q.push(x);
        }else if(n==2){
            if(q.empty()){
                cout << "ERR_CANNOT_POP" << endl;
            }else{
                q.pop();
            }
        }else if(n==3){
            if (q.empty())
            {
                cout << "ERR_CANNOT_QUERY" << endl;
            }
            else
            {
                cout << q.front() << endl;
            }
        }else if(n==4){
            cout << q.size() << endl;
        }
    }
    
    return 0;
}

队列操作模板