#include<iostream>
#include<sstream>
using namespace std;

#define LUNCH 0
#define DINNER 1
#define MIDNIGHT 2
#define OUT 3

int time(int h,int m);

int main()
{
  int n,hh,mm,MM;
  int ok[3],num[3];
  string mes[3]={"lunch ","dinner ","midnight "};
  stringstream ss;
  int i,dif,t;
  char c;

  while(cin>>n,n){
    for(i=0;i<3;i++)ok[i]=num[i]=0;
    for(i=0;i<n;i++){
      cin>>hh>>c>>mm>>MM;
      t=time(hh,mm);
      if(t==OUT)continue;
      if(mm<=MM)dif=MM-mm;
      else dif=60+MM-mm;
      num[t]++;
      ok[t]+=(dif<=8);
    }
    ss.str("");
    for(i=0;i<3;i++){
      ss<<mes[i];
      if(num[i])ss<<100*ok[i]/num[i]<<endl;
      else ss<<"no guest\n";
    }
    cout<<ss.str();
  }
}

int time(int h,int m){
  int t;
  if(h<2)h+=24;
  t=h*100+m;
  if(1100<=t&&t<=1459)return LUNCH;
  else if(1800<=t&&t<=2059)return DINNER;
  else if(2100<=t&&t<=2559)return MIDNIGHT;
  else return OUT;
}