#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define P(type,x,y) fprintf(stdout,#x" %"#type"\n",x*100/y)

int main() {
	int h, m, M, lunch, dinner, midnight, n, cl, cd, cm;
	
	for (; fscanf(stdin, "%d", &n), n != 0; ) {
		lunch = dinner = midnight = cl = cd = cm = 0;
		while (n--) {
			fscanf(stdin, "%d%*c%d%d", &h, &m, &M);
			if (m > M) M += 60;
			if (11 <= h&&h < 15) { cl++; if(M - m <= 8)lunch++;}
			else if (18 <= h&&h < 21) { cd++; if (M - m <= 8)dinner++; }
			else if (h < 2 || 21 <= h) { cm++; if (M - m <= 8)midnight++; }
		}
		if (cl) P(d,lunch,cl);
		else puts("lunch no guest");
		if (cd) P(d, dinner,cd);
		else puts("dinner no guest");
		if (cl) P(d, midnight,cm);
		else puts("midnight no guest");
	}
	return 0;
}