#include <stdbool.h>
#include <stdio.h>
#include<string.h>
typedef struct Queue * PtrQ;
struct Queue{
int x[100000];
int top;
int butt;
};
PtrQ initQueue(void);
_Bool push(PtrQ Q, int x);
int pop(PtrQ Q);
int front(PtrQ Q);
int main(void)
{
int n, i, ret, t, ans;
char op[5];
PtrQ Q;
_Bool B;
Q = initQueue();
scanf("%d",&n);
for(i = 0; i < n; i++)
{
ret = scanf("%s %d",op, &t);
if(ret == 1)
{
if(strcmp(op,"pop") == 0)
{
if(Q->top == Q->butt)
printf("error\n");
else
{
ans = pop(Q);
printf("%d\n",ans);
}
}
else
{
if(Q->top == Q->butt)
printf("error\n");
else
{
ans = front(Q);
printf("%d\n",ans);
}
}
}
else
{
B = push(Q,t);
}
}
}
PtrQ initQueue(void)
{
PtrQ Q;
Q = (PtrQ)malloc(sizeof(struct Queue));
Q->butt = -1;
Q->top = -1;
return Q;
}
_Bool push(PtrQ Q, int x)
{
if(Q->butt + 1 < 100000)
{
Q->x[++Q->butt] = x;
return true;
}
else {
return false;
}
}
int pop(PtrQ Q)
{
int ans;
ans = (Q->x[Q->top+1]);
Q->top++;
return ans;
}
int front(PtrQ Q)
{
return(Q->x[Q->top+1]);
}