#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

struct Node{
	Node(){
		prev = 0;
		next = 0;
		left = width = cat_id = 0;
	}
	int left,width,cat_id;
	Node* prev;
	Node* next;
};

class List{
public:
	List(int W){
		motherNode = new Node();

		motherNode->next = new Node();
		motherNode->next->left = 0;
		motherNode->next->width = W;
		motherNode->next->cat_id = -1;
		motherNode->prev = motherNode->next;
		motherNode->next->prev = motherNode;
		motherNode->next->next = motherNode;
	};

	int sleepCat(int arg_id,int arg_width){
		bool FLG = false;
		Node* tmpNode = motherNode->next;
		int ret;

		while(tmpNode != motherNode){
			if(tmpNode->cat_id != -1){
				tmpNode = tmpNode->next;
			}else{
				if(tmpNode->width >= arg_width){
					FLG = true;
					ret = tmpNode->left;
					if(tmpNode->width == arg_width){
						tmpNode->cat_id = arg_id;
						break;
					}else{

						Node* newNode = new Node();
						newNode->cat_id = -1;
						newNode->width = tmpNode->width - arg_width;
						newNode->left = tmpNode->left + arg_width;
						newNode->prev = tmpNode;
						newNode->next = tmpNode->next;
						tmpNode->next->prev = newNode;
						tmpNode->next = newNode;
						tmpNode->width = arg_width;
						tmpNode->cat_id = arg_id;
						break;
					}
				}else{
					tmpNode = tmpNode->next;
				}
			}
		}

		if(!FLG)return -1;
		else {
			return ret;
		}
	}

	void awakeCat(int arg_id){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode){
			if(tmpNode->cat_id != arg_id){
				tmpNode = tmpNode->next;
			}else{
				if((tmpNode->prev == motherNode || tmpNode->prev->cat_id != -1) && (tmpNode->next == motherNode || tmpNode->next->cat_id != -1)){
					tmpNode->cat_id = -1;
					break;
				}else if((tmpNode->prev == motherNode || tmpNode->prev->cat_id != -1) && (tmpNode->next != motherNode && tmpNode->next->cat_id == -1)){
					tmpNode->cat_id = -1;
					tmpNode->width += tmpNode->next->width;
					tmpNode->next->next->prev = tmpNode;
					tmpNode->next = tmpNode->next->next;
					break;
				}else if((tmpNode->prev != motherNode && tmpNode->prev->cat_id == -1) && (tmpNode->next == motherNode || tmpNode->next->cat_id != -1)){
					tmpNode->prev->width += tmpNode->width;
					tmpNode->prev->next = tmpNode->next;
					tmpNode->next->prev = tmpNode->prev;
					break;
				}else if((tmpNode->prev != motherNode && tmpNode->prev->cat_id == -1) && (tmpNode->next != motherNode && tmpNode->next->cat_id == -1)){
					tmpNode->prev->width += (tmpNode->width + tmpNode->next->width);
					tmpNode->prev->next = tmpNode->next->next;
					tmpNode->next->next->prev = tmpNode->prev;
					break;
				}
			}
		}
	}

private:
	Node* motherNode;
};


void func(int W,int Q){

	List list(W);

	char type[2];
	int id,width,tmp;

	for(int loop = 0; loop < Q; loop++){
		scanf("%s",type);

		if(type[0] == 'w'){
			scanf("%d",&id);
			list.awakeCat(id);
		}else{
			scanf("%d %d",&id,&width);
			tmp = list.sleepCat(id,width);

			if(tmp == -1)printf("impossible\n");
			else{
				printf("%d\n",tmp);
			}
		}
	}
}


int main(){

	int W,Q;

	while(true){
		scanf("%d %d",&W,&Q);
		if(W == 0 && Q == 0)break;

		func(W,Q);
		printf("END\n");
	}

	return 0;
}

Measured memory_bytes: 2728