#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
  int n;
  int h, m, mm;
  while(cin >> n, n){
    double L=0, D=0, M=0;
    int L_cnt=0, D_cnt=0, M_cnt=0;
    for(int i = 0 ; i < n ; i++){
      scanf("%d:%d", &h, &m);
      if(h == 0) h = 24;
      if(h == 1) h = 25;
      scanf("%d", &mm);
      
      int mmm = h * 60 + m;
      
      bool flag = false;
      
      int t = mm - m;
      if(t < 0){
	mm += 60;
	t = mm - m;
      }
      if(t <= 8) flag = true;
      
      if(flag){
	if(660 <= mmm && mmm <= 899){
	  L += 100;
	  L_cnt++;
	}
	else if(1080 <= mmm && mmm <= 1259){
	  D += 100;
	  D_cnt++;
	}
	else if(1260 <= mmm && mmm <= 1559){
	  M += 100;
	  M_cnt++;
	}
      }
      else{
	if(660 <= mmm && mmm <= 899) L_cnt++;
	else if(1080 <= mmm && mmm <= 1259) D_cnt++;
	else if(1260 <= mmm && mmm <= 1559) M_cnt++;
      }
    }
    
    if(L_cnt == 0) cout << "lunch no guest" << endl;
    else cout << "lunch " << (int)L / L_cnt << endl;
    
    if(D_cnt == 0) cout << "dinner no guest" << endl;
    else cout << "dinner " << (int)D / D_cnt << endl;
    
    if(M_cnt == 0) cout << "midnight no guest" << endl;
    else cout << "midnight " << (int)M / M_cnt << endl;
  }
  return 0;
}