//通过可变数组vector实现队列
#include <iostream>
#include <vector>
using namespace std;
vector<int> queue;
void push(int val) {
queue.push_back(val);
}
void pop() {
if (queue.size() == 0)
cout << "error\n";
else {
// cout << "aaa";
printf("%d\n",*queue.begin());
queue.erase(queue.begin());
}
}
void front() {
if (queue.size() == 0)
cout << "error\n";
else {
printf("%d\n",*queue.begin());
}
}
int main() {
int n;
cin >> n;
string s;
getchar();
for (int i = 0; i < n; i++) {
getline(cin, s);
// cout << s << "\n";
if (s != "") {
int index = s.find(' ');
if (index > 0) {
string a = s.substr(0, index);
string b = s.substr(index + 1, s.size());
push(atoi(b.c_str()));
} else {
if (s == "pop") pop(); else front();
}
}
}
}