#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define wall_max 100
#define pos(a)
typedef struct wall{
	int iti;
	int catid;
	int catleng;
	struct wall* nextcat;
};

int typechk(char record[], int* num1, int* num2){
	char *wkptr = NULL;
	char wkchar[256];
	int wknum = 0;
	int slen = 0;

	if(strncmp(record,"0",1) == 0){
		return 1;
	}else if(strncmp(record,"s",1) == 0){
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num2) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num1) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
		return 2;
	}else if(strncmp(record,"w",1) == 0){
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num1) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
		return 3;
	}else{
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num2) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
			(*num1) = atoi(record);
		return 4;
	}
}

void initwall(wall* rewall){
	int i=0;

	for(i=0;i<wall_max;i++){
		rewall[i].iti= i;
		rewall[i].catid = -1;
		rewall[i].catleng = 0;
		rewall[i].nextcat = NULL;
	}
	return;
}
int main(){
	int num1, num2;
	int i=0;
	int type=0;
	char kiroku[256];
	int dataset = 0;
	wall myhouse[wall_max];
	int wallend;
	wall *bfpt = NULL;
	wall *nxpt = NULL;
	wall *curpt = NULL;
	int cmcatid;
	int cmcatleng;
	int tindex;
	int flg=0;

	while(1){
		// ?¨????????????????
		gets_s(kiroku);
		type = typechk(kiroku, &num1, &num2);
		if(type == 1){ // ???????????????
			printf("END\n");
			break;
		}
		else if(type == 4){ // ??\?????\
			if(flg!=0){
				printf("END\n");
			}else{
				flg = 1;
			}
			initwall(myhouse);
			wallend = num1;
		}
		else if(type == 2){ // ?????\???
			cmcatid = num1;
			cmcatleng = num2;
			curpt = myhouse;
			while(1){
				if(curpt->catid == -1){
					if(curpt->nextcat != NULL){
						if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							printf("%d\n",curpt->iti);
							break;
						}
						else{
							curpt = curpt->nextcat;
						}
					}
					else{
						if(cmcatleng <= (wallend - curpt->iti)){ // ????????????
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							printf("%d\n",curpt->iti);
							break;
						}
					}
				}
				else{
					if(curpt->nextcat == NULL){ // ??????????????????????????£???
						if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬??????????
							bfpt = curpt;
							curpt+=curpt->catleng;
							bfpt->nextcat = curpt;
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							printf("%d\n",curpt->iti);
							break;
						}
						else{
							printf("impossible\n"); // ????????°???
							break;
						}
					}
					else{ // ?¬???????
						// ??????????????????
						if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){
							bfpt = curpt;
							nxpt = curpt->nextcat;
							curpt+=curpt->catleng;
							bfpt->nextcat = curpt;
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							curpt->nextcat = nxpt;
							printf("%d\n",curpt->iti);
							break;
						}
						else{
							curpt = curpt->nextcat;
						}
					}
				}
			}
		}
		else if(type == 3){ // ?????°??£???
			cmcatid = num1;
			bfpt = NULL;
			curpt = myhouse;
			while(1){
				if(curpt->catid == cmcatid){
					if(bfpt!=NULL){
						bfpt->nextcat = curpt->nextcat;
					}
					curpt->catid = -1;
					curpt->catleng = 0;
					if( curpt->iti != 0){
						curpt->nextcat = NULL;
					}
					break;
				}
				else{
					bfpt = curpt;
					if(curpt->nextcat!=NULL){
						curpt = curpt->nextcat;
					}
					else{
						break; // ?????????????????????
					}
				}
			}
		}
	}
  
  return 0;
}