fun main(args: Array<String>?): Unit {
    while (true) {
        val (width, q) = readLine()!!.trim().split(' ').map(String::toInt)
        if (width == 0) break;
        val state = Array(width){-1}
        repeat(q) {
            val arg = readLine()!!.trim().split(' ')
            if (arg.first() == "s") {
                var pos = -1
                val id = arg[1].toInt()
                val w = arg[2].toInt()
                for (left in 0 .. width - w) {
                    if ((0 until w).all{state[left + it] == -1}) {
                        pos = left
                        break
                    }
                }
                when(pos) {
                    -1 -> println("impossible")
                    else -> {
                        (0 until w).forEach { state[pos + it] = id }
                        println(pos)
                    }
                }
            }else {
                val id = arg[1].toInt()
                state.indices.forEach{if (state[it] == id) state[it] = -1}
            }
        }
        println("END")
    }
}
