#include <iostream>
#include <string>
#include <queue>
using namespace std;
int main() {
int n;
cin >> n;
queue<int> d;
while (n--) {//一开始我觉得我也是神人,我看到第一组数据,我直接想输入字符串然后再判断。。。卡了好久,
int op;
cin >> op;
if (op == 1) {
// 操作1:入队
int x;
cin >> x; // 读取要入队的值
d.push(x);
} else if (op == 2) {
// 操作2:出队
if (!d.empty()) {
d.pop();
} else {
cout << "ERR_CANNOT_POP" << endl;
}
} else if (op == 3) {
// 操作3:查询队首
if (!d.empty()) {
cout << d.front() << endl;
} else {
cout << "ERR_CANNOT_QUERY" << endl;
}
} else if (op == 4) {
// 操作4:查询大小
cout << d.size() << endl;
}
}
return 0;
}