import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    private static int[] q = new int[100001];
    private static int begin = 0;
    private static int end = 0;
    private static int capacity;

    private static boolean isFull() {
        return ((end + 1) % capacity) == begin;
    }

    private static boolean isEmpty() {
        return end == begin;
    }

    private static void push(int num) {
        q[end] = num;
        end = (end + 1) % capacity;
    }

    private static int front() {
        return q[begin];
    }

    private static int pop() {
        int ret = q[begin];
        begin = (begin + 1) % capacity;
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        in.nextLine();  

        capacity = n + 1;
        for (int i = 1; i <= q; ++i) {
            String line = in.nextLine();
            String[] command = line.split("\\s+");
            if (command[0].equals("push")) {
                int num = Integer.parseInt(command[1]);
                if (isFull()) {
                    System.out.println("full");
                } else {
                    push(num);
                }
            } else if (command[0].equals("front")) {
                if (isEmpty()) {
                    System.out.println("empty");
                } else {
                    System.out.println(front());
                }
            } else if (command[0].equals("pop")) {
                if (isEmpty()) {
                    System.out.println("empty");
                } else {
                    System.out.println(pop());
                }
            }
            // System.out.printf(" %d %d\n", begin, end);
        }
    }
}