3 1
erase -1
erase 0
erase -2147483648
 26 25
defragment
erase 1
erase -1560200883
alloc 44
defragment
alloc 75
alloc 22
defragment
erase 4
defragment
alloc 57
alloc 53
erase 4
erase -1639632026
erase -2121605039
erase 3
alloc 51
alloc 65
defragment
erase 2
erase 4
alloc 52
erase 3
defragment
erase -1842529282
erase 3
 12 40
erase 1
alloc 21
alloc 5
alloc 7
defragment
defragment
erase 2
alloc 83
erase 4
defragment
alloc 59
defragment
 44 46
alloc 28
alloc 36
defragment
erase -937404236
alloc 71
defragment
alloc 81
alloc 51
erase 3
defragment
alloc 48
erase 1
defragment
alloc 36
defragment
defragment
erase 1
defragment
defragment
erase -1173350787
alloc 94
erase 5
defragment
erase 9
alloc 98
erase 7
defragment
erase 5
erase 1
defragment
erase 2
defragment
erase 4
defragment
erase 9
alloc 8
defragment
erase 9
defragment
defragment
defragment
erase 1
alloc 70
erase 9
 7 6
alloc 1
alloc 2
alloc 3
erase 1
defragment
erase 3
alloc 4
 47 43
erase 1
alloc 95
alloc 53
erase 2
defragment
alloc 100
erase 4
erase 2
erase -849472053
defragment
erase -638355221
alloc 90
erase 3
erase 2
defragment
alloc 17
erase 5
defragment
erase 6
defragment
erase 3
defragment
defragment
alloc 99
alloc 69
alloc 80
erase 9
erase 5
defragment
erase 7
defragment
alloc 93
defragment
defragment
alloc 25
defragment
alloc 14
erase 8
erase 4
defragment
defragment
alloc 96
erase 9
alloc 63
erase 8
defragment
erase 10
 8 50
alloc 51
defragment
alloc 100
defragment
erase 1
alloc 50
defragment
alloc 50
 6 1
defragment
alloc 10
alloc 1
erase -1
erase 1
erase 1
 26 25
alloc 25
erase 1
alloc 24
erase 2
alloc 23
erase 3
alloc 24
erase 4
alloc 24
erase 5
alloc 21
erase 6
alloc 24
erase 7
alloc 25
erase 8
alloc 25
erase 9
alloc 24
erase 10
alloc 25
erase 11
alloc 25
erase 12
alloc 25
erase 13
 10 10
alloc 10
erase -1
erase 1
alloc 5
erase -1
alloc 5
erase 0
alloc 5
erase 0
alloc 5
 37 74
alloc 11
defragment
erase 1
defragment
erase 2
defragment
alloc 90
erase 3
erase 2
erase 3
erase 1
erase 1
alloc 38
alloc 19
erase 1
erase 3
defragment
alloc 93
erase 5
erase 4
alloc 66
alloc 71
erase 5
defragment
defragment
defragment
defragment
erase 7
alloc 47
erase -95616683
erase 2
alloc 28
alloc 32
erase 11
alloc 50
defragment
defragment
 19 46
alloc 21
erase 2
erase 1
defragment
alloc 4
defragment
defragment
alloc 40
erase 1
defragment
defragment
alloc 68
erase -388966015
alloc 85
alloc 53
erase 4
defragment
alloc 49
alloc 88
 12 10
alloc 6
alloc 2
erase 1
alloc 4
alloc 2
erase 3
alloc 2
alloc 3
alloc 1
alloc 1
alloc 1
alloc 1
 16 10
alloc 10
defragment
defragment
defragment
alloc 10
erase 1
erase 2
alloc 6
defragment
defragment
alloc 4
defragment
defragment
erase 2
defragment
alloc 6
 14 100
alloc 99
alloc 1
alloc 1
erase 2
alloc 1
erase 4
erase 1
alloc 100
alloc 1
alloc 99
defragment
erase 4
alloc 100
alloc 99
 22 9
alloc 9
erase 1
alloc 9
erase 2
alloc 9
erase 3
alloc 9
erase 4
alloc 9
erase 5
alloc 9
erase 6
alloc 9
erase 7
alloc 9
erase 8
alloc 9
erase 9
alloc 9
erase 10
alloc 9
erase 11
 42 98
defragment
defragment
defragment
defragment
defragment
alloc 5
alloc 66
defragment
erase 3
alloc 53
defragment
erase 4
erase 2
alloc 70
erase 3
defragment
defragment
erase 2
erase 3
erase -1327931832
alloc 93
alloc 64
erase 7
erase 6
erase 3
alloc 61
alloc 12
alloc 65
erase 2
alloc 46
erase 11
erase 9
erase 9
erase 6
alloc 2
alloc 78
defragment
erase 13
erase 6
erase 10
alloc 53
alloc 46
 16 10
alloc 10
defragment
defragment
defragment
alloc 10
erase 1
erase 2
alloc 6
defragment
defragment
alloc 4
defragment
defragment
erase 3
defragment
alloc 6
 38 18
alloc 72
erase 2
alloc 50
defragment
erase 3
defragment
alloc 43
alloc 41
defragment
defragment
alloc 26
alloc 46
alloc 16
alloc 15
defragment
defragment
alloc 95
erase 7
erase 7
erase 5
erase 2
erase 9
erase 7
alloc 43
defragment
erase 7
defragment
alloc 48
alloc 77
erase 10
erase 11
alloc 16
alloc 84
erase 1
defragment
alloc 86
defragment
erase 13
 16 49
erase -751005193
defragment
alloc 37
alloc 82
erase 3
erase 1
alloc 80
alloc 51
defragment
alloc 74
erase 1
alloc 91
defragment
defragment
alloc 98
defragment
 22 9
erase 1
alloc 6
alloc 65
erase 1
alloc 87
erase -1638927047
alloc 5
erase 2
alloc 70
defragment
alloc 20
alloc 48
erase -69401977
alloc 20
defragment
erase 7
defragment
erase 9
erase 7
erase 4
defragment
alloc 66
 7 100
alloc 100
erase 2147483647
erase 1
alloc 50
alloc 50
erase 3
erase -2147483648

ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
1
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 ILLEGAL_ERASE_ARGUMENT
1
2
3
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
 1
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
2
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
3
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
 1
2
3
4
 ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
1
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
2
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 NULL
NULL
ILLEGAL_ERASE_ARGUMENT
1
NULL
 NULL
1
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 1
2
3
4
5
6
7
8
9
10
11
12
13
 1
ILLEGAL_ERASE_ARGUMENT
2
ILLEGAL_ERASE_ARGUMENT
3
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
 1
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
2
3
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
4
5
ILLEGAL_ERASE_ARGUMENT
NULL
 1
ILLEGAL_ERASE_ARGUMENT
2
3
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
 1
2
3
4
5
NULL
6
7
8
9
 1
NULL
ILLEGAL_ERASE_ARGUMENT
2
3
4
 1
2
NULL
3
ILLEGAL_ERASE_ARGUMENT
NULL
4
NULL
NULL
NULL
 1
2
3
4
5
6
7
8
9
10
11
 1
2
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
3
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
4
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
 1
NULL
ILLEGAL_ERASE_ARGUMENT
2
3
NULL
 NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
NULL
1
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
 ILLEGAL_ERASE_ARGUMENT
1
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
 ILLEGAL_ERASE_ARGUMENT
1
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
2
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
 1
ILLEGAL_ERASE_ARGUMENT
2
3
ILLEGAL_ERASE_ARGUMENT

import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

 
 
public class Main {
	
	
	public static void main(String[] args) throws Exception {
        solve(1);	
    }
 
    
    public static void solve(int testCases) throws Exception{
    	int t = StdIn.readInt();
    	int m = StdIn.readInt();
    	Memory mem = new Memory(m);
    	while(t-- > 0){
    		String line = StdIn.readString();
    		if(line.equals("alloc")){
    			StdOut.println(mem.alloc(StdIn.readInt()));
    		}else if(line.equals("erase")){
    			mem.erase(StdIn.readInt());
    		}else{
    			mem.defragment();
    		}
    	}
    }
}


class Memory{
	int[] blocks;
	int blen;
	int id;
	
	public Memory(int n){
		blen = n;
		blocks = new int[n];
		id = 0;
	}
	
	public String alloc(int n){
		//StdOut.println("alloc called with : " + n);
		for(int i = 0 ; i < blen ; i++){
			int a = 0;
			for(int j = i ; j < blen ; j++){
				if(blocks[j]!=0)
					break;
				a++;
			}
			if(a >= n){
				id += 1;
				for(int p = i ; p < (i+n); p++){
					blocks[p] = id;
				}
				return String.valueOf(id);
			}
		}
		return "NULL";
	}
	
	public void erase(int x){
		boolean flag = false;
		for(int i = 0 ; i < blen ; i++){
			if(blocks[i] == x && x!= 0){
				blocks[i] = 0;
				flag = true;
			}
		}
		if(!flag)
			StdOut.println("ILLEGAL_ERASE_ARGUMENT");
	}
	
	public void defragment(){
		int[] temp = new int[blen];
		int j = 0;
		for(int i = 0 ; i < blen ; i++){
			if(blocks[i] != 0)
				temp[j++] = blocks[i];
		}
		blocks = temp;
	}
}

final class StdIn {
 
    private StdIn() { }
 
    private static Scanner scanner;
    
    private static final String CHARSET_NAME = "UTF-8";
 
    private static final Locale LOCALE = Locale.US;
 
    private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\p{javaWhitespace}+");
 
    private static final Pattern EMPTY_PATTERN = Pattern.compile("");
 
    private static final Pattern EVERYTHING_PATTERN = Pattern.compile("\\A");
 
    public static boolean isEmpty() {
        return !scanner.hasNext();
    }
 
    public static boolean hasNextLine() {
        return scanner.hasNextLine();
    }
 
    public static boolean hasNextChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        boolean result = scanner.hasNext();
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return result;
    }
 
    public static String readLine() {
        String line;
        try                 { line = scanner.nextLine(); }
        catch (Exception e) { line = null;               }
        return line;
    }
 
    public static char readChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        String ch = scanner.next();
        assert (ch.length() == 1) : "Internal (Std)In.readChar() error!"
            + " Please contact the authors.";
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return ch.charAt(0);
    }  
 
 
    public static String readAll() {
        if (!scanner.hasNextLine())
            return "";
 
        String result = scanner.useDelimiter(EVERYTHING_PATTERN).next();
        // not that important to reset delimeter, since now scanner is empty
        scanner.useDelimiter(WHITESPACE_PATTERN); // but let's do it anyway
        return result;
    }
 
    public static String readString() {
        return scanner.next();
    }
 
    public static int readInt() {
        return scanner.nextInt();
    }
 
    public static double readDouble() {
        return scanner.nextDouble();
    }
 
    public static float readFloat() {
        return scanner.nextFloat();
    }
 
    public static long readLong() {
        return scanner.nextLong();
    }
    
    public static short readShort() {
        return scanner.nextShort();
    }
 
    public static byte readByte() {
        return scanner.nextByte();
    }
 
    public static boolean readBoolean() {
        String s = readString();
        if (s.equalsIgnoreCase("true"))  return true;
        if (s.equalsIgnoreCase("false")) return false;
        if (s.equals("1"))               return true;
        if (s.equals("0"))               return false;
        throw new InputMismatchException();
    }
 
    public static String[] readAllStrings() {
        // we could use readAll.trim().split(), but that's not consistent
        // because trim() uses characters 0x00..0x20 as whitespace
        String[] tokens = WHITESPACE_PATTERN.split(readAll());
        if (tokens.length == 0 || tokens[0].length() > 0)
            return tokens;
 
        // don't include first token if it is leading whitespace
        String[] decapitokens = new String[tokens.length-1];
        for (int i = 0; i < tokens.length - 1; i++)
            decapitokens[i] = tokens[i+1];
        return decapitokens;
    }
 
    public static String[] readAllLines() {
        ArrayList<String> lines = new ArrayList<String>();
        while (hasNextLine()) {
            lines.add(readLine());
        }
        return lines.toArray(new String[0]);
    }
 
    public static int[] readAllInts() {
        String[] fields = readAllStrings();
        int[] vals = new int[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Integer.parseInt(fields[i]);
        return vals;
    }
 
    public static double[] readAllDoubles() {
        String[] fields = readAllStrings();
        double[] vals = new double[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Double.parseDouble(fields[i]);
        return vals;
    }
    
    static {
        resync();
    }
 
    private static void resync() {
        setScanner(new Scanner(new java.io.BufferedInputStream(System.in), CHARSET_NAME));
    }
    
    private static void setScanner(Scanner scanner) {
        StdIn.scanner = scanner;
        StdIn.scanner.useLocale(LOCALE);
    }
 
    public static int[] readInts() {
        return readAllInts();
    }
 
    public static double[] readDoubles() {
        return readAllDoubles();
    }
 
    public static String[] readStrings() {
        return readAllStrings();
    }
 
}
 
final class StdOut {
 
    private static final String CHARSET_NAME = "UTF-8";
 
    private static final Locale LOCALE = Locale.US;
 
    private static PrintWriter out;
 
    static {
        try {
            out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true);
        }
        catch (UnsupportedEncodingException e) { System.out.println(e); }
    }
 
    private StdOut() { }
 
    public static void close() {
        out.close();
    }
 
    public static void println() {
        out.println();
    }
 
    public static void println(Object x) {
        out.println(x);
    }
 
    public static void println(boolean x) {
        out.println(x);
    }
 
    public static void println(char x) {
        out.println(x);
    }
 
    public static void println(double x) {
        out.println(x);
    }
 
    public static void println(float x) {
        out.println(x);
    }
 
    public static void println(int x) {
        out.println(x);
    }
 
    public static void println(long x) {
        out.println(x);
    }
 
    public static void println(short x) {
        out.println(x);
    }
 
    public static void println(byte x) {
        out.println(x);
    }
 
    public static void print() {
        out.flush();
    }
 
    public static void print(Object x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(boolean x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(char x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(double x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(float x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(int x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(long x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(short x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(byte x) {
        out.print(x);
        out.flush();
    }
 
    public static void printf(String format, Object... args) {
        out.printf(LOCALE, format, args);
        out.flush();
    }
 
    public static void printf(Locale locale, String format, Object... args) {
        out.printf(locale, format, args);
        out.flush();
    }
 
} 