#include <bits/stdc++.h>
using namespace std;

template< typename T >
class Treap {
private: // parts
	unsigned int rnd() {
		static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
		unsigned int t = (x ^ (x << 11));
		x = y; y = z; z = w;
		return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
	}
	
	struct Node {
		T val, data, add;
		Node *lch, *rch;
		int pri, cnt;
		bool rev;
		
		Node(T v, int p) : val(v), data(v), add(T(0)), pri(p), cnt(1), rev(false) { lch = rch = nullptr; }
	};
	
	Node *root;
	
private: // main function
	int count(Node* t) { return t ? t->cnt : 0; }
	T data(Node* t) { return t ? t->data : T(1e9); }	
	
	void push(Node* t) {
		if (t && t->rev) {
			swap(t->lch, t->rch);
			if (t->lch) t->lch->rev ^= true;
			if (t->rch) t->rch->rev ^= true;
			t->rev = false;
		}
		
		if (t && t->add != 0) {
			t->val += t->add;
			if (t->lch) t->lch->add += t->add;
			if (t->rch) t->rch->add += t->add;
			t->add = 0;
		}
	}
	
	Node* update(Node *t) {
		if (!t) return t;
		t->cnt = count(t->lch) + count(t->rch) + 1;
		//t->data = calc(calc(data(t->lch), data(t->rch)), t->val);
		return t;
	}
	
	Node* merge(Node* l, Node* r) {
		push(l); push(r);
		
		if (!l || !r) return l ? l : r;
	
		if (l->pri > r->pri) {
			l->rch = merge(l->rch, r);
			return update(l);
		} else {
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}
	
	typedef pair< Node*, Node* > pnn;
	
	pnn split(Node* t, int k) {
		if (!t) return pnn(nullptr, nullptr);
		
		push(t);
		
		if (k <= count(t->lch)) {
			pnn s = split(t->lch, k);
			t->lch = s.second;
			return pnn(s.first, update(t));
		} else {
			pnn s = split(t->rch, k - count(t->lch) - 1);
			t->rch = s.first;
			return pnn(update(t), s.second);
		}
	}
	
	Node* insert(Node* t, int k, T val, int pri) {
		pnn s = split(t, k);
		t = merge(s.first, new Node(val, pri));
		t = merge(t, s.second);
		return update(t);
	}
	
	Node* erase(Node* t, int k) {
		pnn s1 = split(t, k + 1);
		pnn s2 = split(s1.first, k);
		t = merge(s2.first, s1.second);
		delete s2.second;
		return update(t);
	}
	
	Node* find(Node* t, int k) {
		push(t);
		int c = count(t->lch);
		if (k < c) return find(t->lch, k);
		if (k > c) return find(t->rch, k - c - 1);
		return t;
	}
	
	void dump(Node* t, ostream& os) {
		if (!t) return;
		os << "(";
		dump(t->lch, os);
		os << t->val;
		dump(t->rch, os);
		os << ")";
	}
	
public: // public function
	Treap() : root(nullptr) {}
	
	void insert(int k, T val) { root = insert(root, k, val, rnd()); }
	void erase(int k) { root = erase(root, k); }
	Node* find(int k) { return find(root, k); }
	int size() { return count(root); }
	
	void dump(ostream& os) {
		dump(root, os);
		os << endl;
	}
	
	~Treap() { while (root) erase(0); }
};

int Q, L;

void run() {
	long long base = 0;
	Treap< long long > treap;
	
	auto lowerBound = [&](long long x) {
		int lb = -1, ub = treap.size();
		while (ub - lb > 1) {
			int med = (ub + lb) / 2;
			if (treap.find(med)->val < x) lb = med;
			else ub = med;
		}
		return ub;
	};
	
	auto upperBound = [&](long long x) {
		int lb = -1, ub = treap.size();
		while (ub - lb > 1) {
			int med = (ub + lb) / 2;
			if (treap.find(med)->val <= x) lb = med;
			else ub = med;
		}
		return ub;
	};
	
	for (int i=0; i<Q; ++i) {
		int t;
		scanf("%d", &t);
		
		if (t == 0) {
			treap.insert((int)treap.size(), base + L);
		}
		
		if (t == 1) {
			int d;
			scanf("%d\n", &d);
			base += d;
			int num = upperBound(base);
			if (num > 0) printf("damage %d\n", num);
			for (int i=0; i<num; ++i) treap.erase(0);
		}
		
		if (t == 2) {
			int k;
			scanf("%d\n", &k);
			if ((int)treap.size() >= k) puts("hit");
			else puts("miss");
			treap.erase(k-1);
		}
		
		if (t == 3) {
			int x, r;
			scanf("%d %d\n", &x, &r);
			int lft = lowerBound(base + x - r), rgt = upperBound(base + x + r);
			printf("bomb %d\n", rgt - lft);
			for (int i=0; i<rgt-lft; ++i) treap.erase(lft);
		}
		
		if (t == 4) {
			int k;
			scanf("%d\n", &k);
			if ((int)treap.size() >= k) printf("distance %d\n", (int)(treap.find(k-1)->val - base));
			else puts("distance -1");
		}
	}
	
	puts("end");
}

int main() {
	while (cin >> Q >> L, Q) {
		run();
	}
}


Measured memory_bytes: 6300