/*
  AOJ 1515
  Title:The Humans Braving the Invaders
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define min(x,y) (((x)<(y))?(x):(y))
#define max(x,y) (((x)>(y))?(x):(y))

int Q,L;

int inv[100000];
int inv_last,inv_cnt;
int order,arg1,arg2;


int get_nth_inv_no(int n)
{
  int i,c;

  for(i=0,c=0;i<inv_last;i++)
    if(inv[i]>0)
      {
	c++;
	if(c==n)
	  return(i);
      }
  return(-1);
}

void execute(int order,int arg1,int arg2)
{
  int i,damage,c,ret;
  if(order==0)
    {
      inv[inv_last++]=L;
      inv_cnt++;
    }
  if(order==1)
    {
      for(i=damage=0;i<inv_last;i++)
	{
	  if(inv[i]>arg1)
	    inv[i]-=arg1;
	  else if(inv[i] > 0)
	    {
	      inv[i]=-1;
	      inv_cnt--;
	      damage++;
	    }
	}
      if(damage)
	printf("damage %d\n",damage);
    }
  if(order==2)
    if(inv_cnt>=arg1)
      {
	ret=get_nth_inv_no(arg1);
	inv[ret]=-1;
	inv_cnt--;
	printf("hit\n");
      }
    else
      printf("miss\n");
  
  if(order==3)
    {
      for(i=c=0;i<inv_last;i++)
	{
	  if(inv[i] >= max(0,arg1-arg2) && inv[i] <= min(L,arg1+arg2))
	    {
	      inv_cnt--;
	      c++;
	      inv[i]=-1;
	    }
	}
      printf("bomb %d\n",c);
    }
  
  if(order==4)
    {
      ret=get_nth_inv_no(arg1);
      if(ret>=0)
	 printf("distance %d\n",inv[ret]);
      else
	printf("distance -1\n");
    }
}

void dump()
{
  int i;

  for(i=0;i<inv_last;i++)
    printf("%d|",inv[i]);
	   printf("\n");
}

main()
{
  int i,ret;

  while(scanf("%d %d",&Q,&L)  && (Q||L))
    {
      memset(inv,-1,sizeof(inv));
      inv_cnt=0;
      for(i=0;i<Q;i++)
	{
	  scanf("%d",&order);
	  if(order == 1||order==2||order==4)
	    scanf("%d",&arg1);
	  else if (order==3)
	    scanf("%d %d",&arg1,&arg2);
	  execute(order,arg1,arg2);
#ifdef DEBUG
	  dump();
#endif
	}
      printf("end\n");
    }
  return(0);
}