import java.util.Scanner;

/**
 * push x:将 x\x 加入队尾,保证 x\x 为 int 型整数。
 * pop:输出队首,并让队首出队
 * front:输出队首:队首不出队
 * <p>
 * 输入描述:
 * 第一行为一个正整数 n\n ,代表操作次数。(1 \leq n \leq 100000)(1≤n≤100000)
 * 接下来的 n\n ,每行为一个字符串,代表一个操作。保证操作是题目描述中三种中的一种。
 * <p>
 * 输出描述:
 * 如果操作为push,则不输出任何东西。
 * 如果为另外两种,若队列为空,则输出 "error“
 * 否则按对应操作输出。
 */
public class AB7 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());//获取总的操作次数
        CustomQueue<Integer> customQueue = new CustomQueue<>(n);
        while (scan.hasNextLine()) {//获取每一次操作
            String str = scan.nextLine();
            String arr[] = str.split(" ");
            if (arr[0].equals("push")) {
                customQueue.push(Integer.parseInt(arr[1]));
            } else if (arr[0].equals("pop")) {
                customQueue.pop();
            } else {
                customQueue.front();
            }
        }
        scan.close();
    }
}


class CustomQueue<T> {

    private int queueSize;
    private int t1 = 0, t2 = 0;
    private int[] queue;

    public CustomQueue(int queueSize) {
        this.queueSize = queueSize;
        this.queue = new int[queueSize];
    }

    public void push(int x) {
        if (this.t2 == this.queueSize - 1) {
            System.out.println("error");
        } else {
            this.queue[t2++] = x;
        }
    }

    public void pop() {
        if (t1 >= t2) {
            System.out.println("error");
        } else {
            System.out.println(this.queue[t1++]);
        }
    }

    public void front() {
        if (t1 >= t2) {
            System.out.println("error");
        } else {
            System.out.println(this.queue[t1]);
        }
    }
}