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

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 (M - m <= 8) {
				if (11 <= h&&h < 15) lunch++;
				else if (18 <= h&&h < 21) dinner++;
				else if (h <= 2 || 21 <= h) midnight++;
			}
			if (11 <= h&&h < 15) cl++;
			else if (18 <= h&&h < 21) cd++;
			else if (h <= 2 || 21 <= h) cm++;
		}
		if(cl) lunch = lunch* 100 / cl ;
		if(cd)dinner = dinner* 100 / cd ;
		if(cm)midnight = midnight* 100 / cm ;
		if (lunch) P(d,lunch);
		else puts("lunch no guest");
		if (dinner) P(d, dinner);
		else puts("dinner no guest");
		if (midnight) P(d, midnight);
		else puts("midnight no guest");
	}
	return 0;
}