#include <iostream>
using namespace std;
int n, c[3], d[3], h, m, r; char e;
int main() {
	while(cin >> n, n) {
		c[0] = c[1] = c[2] = 0;
		d[0] = d[1] = d[2] = 0;
		for(int i = 0; i < n; i++) {
			cin >> h >> e >> m >> r;
			int t = h * 60 + m, u = (r - m + 60) % 60;
			if(660 <= t && t < 900) c[0]++, d[0] += (u < 9 ? 1 : 0);
			if(1080 <= t && t < 1260) c[1]++, d[1] += (u < 9 ? 1 : 0);
			if(1260 <= t && t < 1440 || t < 120) c[2]++, d[2] += (u < 9 ? 1 : 0);
		}
		cout << "lunch ";
		if(!c[0]) cout << "no guest" << endl;
		else cout << 100 * d[0] / c[0] << endl;
		cout << "dinner ";
		if(!c[1]) cout << "no guest" << endl;
		else cout << 100 * d[1] / c[1] << endl;
		cout << "midnight ";
		if(!c[2]) cout << "no guest" << endl;
		else cout << 100 * d[2] / c[2] << endl;
	}
}