#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	while (scanf("%d", &n), n) {
		int cl = 0, ol = 0, cd = 0, od = 0, cm = 0, om = 0;
		rep(i, n) {
			int h, m, M; scanf("%d:%d%d", &h, &m, &M);
			if (m > M)M += 60;
			if (660 <= h * 60 + m&&h * 60 + m < 900) {
				cl++;
				if (M - m <= 8)ol++;
			}
			if (1080 <= h * 60 + m&&h * 60 + m < 1260) {
				cd++;
				if (M - m <= 8)od++;
			}
			if (1260 <= h * 60 + m || h * 60 + m < 120) {
				cm++;
				if (M - m <= 8)om++;
			}
		}
		printf("lunch ");
		if (!cl)puts("no guest");
		else printf("%d\n", ol * 100 / cl);
		printf("dinner ");
		if (!cd)puts("no guest");
		else printf("%d\n", od * 100 / cd);
		printf("midnight ");
		if (!cm)puts("no guest");
		else printf("%d\n", om * 100 / cm);
	}
}