#include<iostream>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> p;

int dist(int a,int b){
	if(a<b)return a+60-b;
	else return a-b;
}

bool noon(int h,int m){
	if(h*60+m>=11*60 && h*60+m<15*60)return true;
	else return false;
}

bool evening(int h,int m){
	if(h*60+m>=18*60 && h*60+m<21*60)return true;
	else return false;
}

bool night(int h,int m){
	if((h*60+m>=21*60 && h*60+m<24*60)||(h*60+m<2*60))return true;
	else return false;
}

bool last(int h,int m,int s){
	if(h*60+m+s>=2*60)return false;
	else return true;
}

int main(){
	int n;
	while(cin>>n,n){
		int hh,mm,MM,dif;
		p lunch,dinner,midnight;
		lunch=dinner=midnight=p(0,0);
		rep(i,n){
			scanf("%d:%d %d",&hh,&mm,&MM);
			dif=dist(MM,mm);
			if(noon(hh,mm)){
				if(dif<=8)lunch.first++;
				lunch.second++;
			}else if(evening(hh,mm)){
				if(dif<=8)dinner.first++;
				dinner.second++;
			}else if(night(hh,mm)){
				if(dif<=8 /*&& last(hh,mm,MM)*/)midnight.first++;
				midnight.second++;
			}
		}
		int l=(double)lunch.first/(double)lunch.second*100;
		int d=(double)dinner.first/(double)dinner.second*100;
		int m=(double)midnight.first/(double)midnight.second*100;
		if(lunch.second==0)cout<<"lunch no guest"<<endl;
		else 	cout<<"lunch "<<l<<endl;
		if(dinner.second==0)cout<<"dinner no guest"<<endl;
		else	cout<<"dinner "<<d<<endl;
		if(midnight.second==0)cout<<"midnight no guest"<<endl;
		else	cout<<"midnight "<<m<<endl;
	}
	return 0;
}