#include<bits/stdc++.h>
using namespace std;
inline int xor128(void)
{ 
  static int x = 123456789;
  static int y = 362436069;
  static int z = 521288629;
  static int w = 88675123; 
  int t;
   
  t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}
#define int long long
struct Node
{
  int Value;
  int SubTreeSize;
  Node *Lch, *Rch;
  Node(int V):Value(V), SubTreeSize(1) {
    Lch = (Node *)NULL;
    Rch = (Node *)NULL;
  };
};
inline int Count(Node *t)
{
  if(t == (Node *)NULL) return(0);
  else return(t -> SubTreeSize);
}

inline Node *Update(Node *t)
{
  if(t == (Node *)NULL) return((Node *)NULL);
  t -> SubTreeSize = Count(t -> Lch) + Count(t -> Rch) + 1;
  return(t);
}
  
inline Node *MakeRoot(int value)
{
  return(new Node(value));
}
  
Node *Merge(Node *l, Node *r)
{
  if(l == (Node *)NULL) return(r);
  if(r == (Node *)NULL) return(l);
  int Left  = l -> SubTreeSize;
  int Right = r -> SubTreeSize;
  if(xor128() % (Left + Right) < Left) {
    l -> Rch = Merge(l -> Rch, r);
    return(Update(l));
  } else {
    r -> Lch = Merge(l, r -> Lch);
    return(Update(r));
  }
}
    
pair< Node*, Node* > Split(Node *t, int k) // [0, k), [k, n)
{
  if(t == (Node *)NULL) return(make_pair((Node *)NULL, (Node *)NULL));
  if(k <= Count(t -> Lch)) {
    pair< Node *, Node *> s = Split(t -> Lch, k);
    t -> Lch = s.second;
    return(make_pair(s.first, Update(t)));
  } else {
    pair< Node *, Node *> s = Split(t -> Rch, k - Count(t -> Lch) - 1);
    t -> Rch = s.first;
    return(make_pair(Update(t), s.second));
  }
}
  
Node *Insert(Node *root, int pos, int value)
{
  Node *p = MakeRoot(value);
  pair< Node *, Node *> s = Split(root, pos);
  return(Merge(Merge(s.first, p), s.second));
}
 
Node *Erase(Node *root, int pos)
{
  pair< Node *, Node *> s = Split(root, pos);
  pair< Node *, Node *> t = Split(s.second, 1);
  delete t.first;
  return(Merge(s.first, t.second));
}
void EraseALL(Node *root)
{
  if(root        == (Node *)NULL) return;
  if(root -> Lch != (Node *)NULL) EraseALL(root -> Lch);
  if(root -> Rch != (Node *)NULL) EraseALL(root -> Rch);
  delete root;
}

int Lower_Bound(Node *root, int Value)
{
  if(root == (Node *)NULL) return(0);
  if(Value <= root -> Value) return(Lower_Bound(root -> Lch, Value));
  return(Lower_Bound(root -> Rch, Value) + Count(root -> Lch) + 1);
}

void Dump(Node *root)
{
  Update(root);
  if(root == (Node *)NULL) return;
  cout << "(";
  Dump(root -> Lch);
  cout << "" << root -> Value << "";
  Dump(root -> Rch);
  cout << ")";
} 


signed main()
{
  int Q, L;
  Node *root = (Node *)NULL;

  while(true) {
    scanf("%lld %lld", &Q, &L);
    if(Q == 0 && L == 0) break;
    long long D = 0LL;
    while(Q--) {
      int type;
      scanf("%lld", &type);
      if(type == 0) {
        root = Insert(root, Lower_Bound(root, L + D), L + D);
      } else if(type == 1) {
        int d;
        scanf("%lld", &d);
        D += d;
        if(root != (Node *)NULL) {
          pair< Node*, Node* > S = Split(root, Lower_Bound(root, D + 1));
          if(Count(S.first) > 0) {
            printf("damage %lld\n", Count(S.first));
            EraseALL(S.first);
          }
          root = S.second;
        }
      } else if(type == 2) {
        int k;
        scanf("%lld", &k);
        if(Count(root) >= k) {
          root = Erase(root, --k);
          puts("hit");
        } else {
          puts("miss");
        }
      } else if(type == 3) {
        int x, r;
        scanf("%lld %lld", &x, &r);
        pair< Node*, Node* > S = Split(root, Lower_Bound(root, D + x - r));
        pair< Node*, Node* > T = Split(S.second, Lower_Bound(S.second, D + x + r + 1));
        printf("bomb %lld\n", Count(T.first));
        EraseALL(T.first);
        root = Merge(S.first, T.second);
      } else {
        int k;
        scanf("%lld", &k);
        int dist = -1;
        if(Count(root) >= k) {
          pair< Node*, Node* > S = Split(root, --k);
          pair< Node*, Node* > T = Split(S.second, 1);
          dist = T.first -> Value - D;
          S.second = Merge(T.first, T.second);
          root = Merge(S.first, S.second);
        }
        printf("distance %lld\n", dist);
      }
    }
    EraseALL(root);
    root = (Node *)NULL;
    puts("end");
  }
}

Measured memory_bytes: 3356