#include
#include
using namespace std;
class Queue {
private:
int* data;
int front1, rear;
int count;
int size;
public:
Queue(int capacity);
~Queue();
void push(int e);
bool isEmpty();
bool isFull();
void pop();
void front();
};
Queue::Queue(int capacity) {
data = new int[capacity];
size = capacity;
count = 0;
front1 = rear = 0;
}
Queue::~Queue() {
delete[] data;
}
void Queue::push(int e) {
if (isFull()) {
return;
}
data[rear] = e;
rear = (rear + 1) % size;
count++;
}
void Queue::pop() {
if (isEmpty()) {
cout << "error" << endl;
return;
}
cout << data[front1] << endl;
front1 = (front1 + 1) % size;
count--;
}
void Queue::front() {
if (isEmpty()) {
cout << "error" << endl;
return;
}
cout << data[front1] << endl;
}
bool Queue::isFull() {
return count == size;
}
bool Queue::isEmpty() {
return count == 0;
}
int main() {
int n;
cin>>n;
Queue q(n);
string s;
int t;
for (int i = 0; i < n; i++) {
cin >> s;
if (s == "push") {
cin >> t;
q.push(t);
} else if (s == "pop") {
q.pop();
} else if (s == "front") {
q.front();
}
}
}