#include<stdio.h>
int main(){
  int n,h,m,t,i;
  char s[3][10]={"lunch","dinner","midnight"};
  while(scanf("%d",&n),n){
    int o[3]={0};
    int c[3]={0};
    while(n--){
      scanf("%d%*c%d %d",&h,&m,&t);
      if(m>t)t+=60;
      h=h*100+m;
      i=3;
      if(1100<=h&&h<=1459)i=0;
      if(1800<=h&&h<=2059)i=1;
      if(2100<=h&&h<=2400)i=2;
      if(   0<=h&&h<= 159)i=2;
      if(3-i){
	if(t-m<9)o[i]++;
	c[i]++;
      }
    }
    for(i=0;i<3;i++){
      printf("%s ",s[i]);
      if(c[i])printf("%d\n",(o[i]*100)/c[i]);
      else    printf("no guest\n");
    }    
  }
    return 0;
}