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