#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;

const double eps=(1e-8);

int n;

bool check(int x,int y)
{
   if (x<=y) 
   {
      return (y-x<=8);
   }
   return (y+60-x<=8);
}

int calc(int a, int b)
{
     return b*100/a;
}

int main()
{
   int sum[5][2];
   while(scanf("%d",&n)!=EOF)
   {
	  if(n==0) break;
	  memset(sum,0,sizeof(sum));
	  for (int i=1;i<=n;i++)
	  {
		  int h,t1,t2;
		  scanf("%d%*c%d%d",&h,&t1,&t2);
		  if (h>=11&&h<=14)
		  {
		     sum[1][0]++;
			 if (check(t1,t2)) sum[1][1]++;
		  }
		  if (h>=18&&h<=20)
		  {
			 sum[2][0]++;
			 if (check(t1,t2)) sum[2][1]++;
		  }
		  if ((h>=0&&h<=1)||(h>=21&&h<=23))
		  { 
			 sum[3][0]++;
			 if (check(t1,t2)) sum[3][1]++;
		  }
	  }  
	  if (sum[1][0]==0)
	  printf("lunch no guest\n");
	  else
	   {
		  printf("lunch %d\n", calc(sum[1][0], sum[1][1]));
	   }
	  
	  if (sum[2][0]==0)
	  printf("dinner no guest\n");
	  else
	   {
		  printf("dinner %d\n", calc(sum[2][0], sum[2][1]));
	   }
	  
	  if (sum[3][0]==0)
	  printf("midnight no guest\n");
	  else
	   {
		  printf("midnight %d\n", calc(sum[3][0], sum[3][1]));
	   }
   }
   return 0;
}