import java.util.Scanner;
import java.io.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) throws IOException{
       
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       int n=Integer.parseInt(br.readLine());
       ArrayQueue queue=new ArrayQueue(n);
       String str="";
       while((str=br.readLine())!=null){
           if(str.startsWith("push")){  //入队
              int m=Integer.parseInt(str.substring(5));
              queue.add(m);
           }else if(str.startsWith("pop")){
              queue.pop();
           }else if(str.startsWith("front")){
              queue.frot();
           }
       }
    }
 
 static class ArrayQueue{
        private int maxSize;
        private int front;
        private int rear;
        private int[] arr;
 
        public  ArrayQueue(int m) {
            this.maxSize = m;
            arr = new int[maxSize];
            front = -1;   //前
            rear = -1;    //后
        }
 
        public boolean isFull() {//队满
            return rear == maxSize - 1;
        }
 
        public boolean isEmpty() {//队空
            return rear == front; 
        }
        public void add(int num) { //向队中添加元素
            if (isFull()) {
                System.out.print("error\n");
                return;
            }
            rear++;
            arr[rear] = num;
        }
 
        public  void pop() {
            if (isEmpty()) {
                System.out.print("error\n");
                return;
            }
            front++;
            System.out.print(arr[front]+"\n");
 
        }
 
        public  void frot() {
            if (isEmpty()) {
                System.out.print("error\n");
                return;
            }
            System.out.print(arr[front + 1]+"\n");
        }
 
 
 }

}

没看懂啊先留个记号~