#include<stdio.h>
#include<string.h>
typedef struct node{
int data;
struct node *next;
}QNode;
typedef struct{
QNode *front,*rear;
}Queue;
Queue* IntiLine();
int IfEmpty(Queue* x);
void In_Queue(Queue* x,char *str);
void Pop_Queue(Queue* x);
void Front_Queue(Queue* x);
int main(){
int num;
scanf("%d%*c",&num);
char str[20];
int front=0,rear=0;
Queue *queue=IntiLine();
while(scanf("%[^\n]%*c",str)!=EOF){
if(strcmp(str,"pop")==0)
Pop_Queue(queue);
else if(strcmp("front",str)==0)
Front_Queue(queue);
else
In_Queue(queue,str);
}
return 0;
}
Queue* IntiLine(){
Queue *q=malloc(sizeof(Queue));
QNode *p=malloc(sizeof(QNode));
p->next=NULL;
q->front=q->rear=p;
return q;
}
int IfEmpty(Queue* x){
return (x->front==x->rear);
}
void In_Queue(Queue* x,char *str){
char str1[10];
int integer;
sscanf(str, "%s %d",str1,&integer);
QNode *p=malloc(sizeof(QNode));
p->data=integer;
p->next=NULL;
x->rear->next=p;
x->rear=p;
}
void Pop_Queue(Queue* x){
if(IfEmpty(x))
printf("error\n");
else{
QNode *p=malloc(sizeof(QNode));
p=x->front->next;
x->front->next=p->next;
printf("%d\n",p->data);
free(p);
if(x->front->next==NULL)
x->rear=x->front;
}
}
void Front_Queue(Queue* x){
if(IfEmpty(x))
printf("error\n");
else
printf("%d\n",x->front->next->data);
}