#include<stdio.h>
int main()
{
	int n,i,a,b,d,e,f,g;
	int lunchsum,dinnersum,midnightsum,lunchss,dinnerss,midnightss;
	char c;
	while(scanf("%d",&n)&&(n!=0))
	{ 
		
		lunchsum=0;
		dinnersum=0;
		midnightsum=0;
		lunchss=0;
		dinnerss=0;
		midnightss=0;
		for(i=0;i<n;i++)
		{
			scanf("%d%c%d%d",&a,&c,&b,&d);
			if(a>=11&&a<=14)
			{
				lunchsum++;
				if((d-b)<=8&&(d-b)>=0)
					lunchss++;
			 if((d-b)<0)
				{
					if((d+60-b)<=8&&(a!=14))
						lunchss++;
				}
			}
		 if(a>=18&&a<=20)
				
			{
				dinnersum++;
				if((d-b)<=8&&(d-b)>=0)
					dinnerss++;
			 if((d-b)<0)
				{
					if((d+60-b)<=8)
						dinnerss++;
				}
			}
			if((a>=21&&a<=23)||(a<=1&&a>=0))
			{
				midnightsum++;
				if((d-b)<=8&&(d-b)>=0)
					midnightss++;
			if((d-b)<0)
				{
					if((d+60-b)<=8)
						midnightss++;
				}
			}
		}
		if(lunchsum>0)
			e=100*lunchss/lunchsum;
		if(dinnersum>0)
			f=100*dinnerss/dinnersum;
		if(midnightsum>0)
			g=100*midnightss/midnightsum;
		
		if(lunchsum>0)
			printf("lunch %d\n",e);
		else
			printf("lunch no guest\n");
		if(dinnersum>0)
			printf("dinner %d\n",f);
		else
			printf("dinner no guest\n");
		if(midnightsum>0)
			printf("midnight %d\n",g);
		else
			printf("midnight no guest\n");
	}
	return 0;
}