#include<stdio.h>
#include<string.h>
int N,ll,mm,t1,t2,p[2][4],i;
char *t[3]={"lunch","dinner","midnight"};

int f(int t)
{
	if(660<=t1&&t1<900)
		return 0;
	if(1080<=t1&&t1<1260)
		return 1;
	if(1260<=t1&&t1<1560)
		return 2;
	return 3;
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		memset(p,0,sizeof(p));
		for(;N--;)
		{
			scanf("%d:%d%d",&ll,&mm,&t2);
			if(ll<11)ll+=24;
			t1=ll*60+mm;
			t2=(mm<=t2?ll:ll+1)*60+t2;
			//printf("%d\n",f(t1));
			if(t2-t1<=8)
				p[1][f(t1)]++;
			p[0][f(t1)]++;
		}
		for(i=0;i<3;i++)
		{
			printf("%s ",t[i]);
			if(p[0][i])printf("%d\n",p[1][i]*100/p[0][i]);
			else puts("no guest");
		}
	}
	return 0;
}