#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int cnt1[5],cnt2[5];
int n;
const double eps=1e-8; 
int be[5],ed[5]; 
int change(int h,int m){
	if (h*60+m<120) return h*60+m+24*60;
	else return h*60+m; 
}
void init(){
	be[0]=11*60;ed[0]=14*60+59;
	be[1]=18*60;ed[1]=20*60+59;
	be[2]=21*60;ed[2]=60+59+24*60; 
} 
int main()
{
	init();	
	int h,m1,m2; 
	while (~scanf("%d",&n),n)
	{
		memset(cnt1,0,sizeof(cnt1));
		memset(cnt2,0,sizeof(cnt2)); 
		for (int i=0;i<n;i++){
			scanf("%d:%d%d",&h,&m1,&m2);
			int t=change(h,m1); 
			for (int j=0;j<3;j++){
				if (be[j]<=t && t<=ed[j]) 
				{
					cnt1[j]++;
					if (m1>m2) m2+=60;
					if (m2-m1<=8) cnt2[j]++; 
					break; 
				} 
			} 	
		} 
		if (cnt1[0]) 
		printf("lunch %d\n",(int)((cnt2[0]*1.0/cnt1[0]+eps)*100));
		else printf("lunch no guest\n");
 		if (cnt1[1]) 
		printf("dinner %d\n",(int)((cnt2[1]*1.0/cnt1[1]+eps)*100));
		else printf("dinner no guest\n");
		if (cnt1[2]) 
		printf("midnight %d\n",(int)((cnt2[2]*1.0/cnt1[2]+eps)*100));
		else printf("midnight no guest\n");
	}				
	return 0; 
} 