#include<stdio.h>


int main(void){
	int n,cnt,a,b,c,i,m;
	int cnt1 =0;
	int cnt2 =0;
	int L=0;
	int D=0;
	int M=0;
	int LP,DP,MP;

	cnt = 0;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d%*c%d%d",&a, &b, &c);
		if(a == 0)
			break; 
		m = a * 60 + b;
		if(m<660){
			M++;
		if(c-b<=8){
			cnt++;
		}else if(c-b<0){
			if((60-b)+c<=8){
				cnt++;
			}
		}
		}else if(m<900){
			L++;
			if(c-b<=8){
			cnt++;
		}else if(c-b <0){
			if((60-b)+c<=8){
				cnt1++;
			}
			}
		}else if(m<1260){
			D++;
			if(c-b<=8){
			cnt++;
		}else if(c-b<0){
			if((60-b)+c<=8){
				cnt2++;
			}
			}
		}else if(m<=1440){
			M++;
			if(c-b<=8){
			cnt++;
		}else if(c-b<0){
			if((60-b)+c<=8){
				cnt++;
			}
			}
		}

	}

	if(cnt1==0){
		printf("lunch no guest\n");
	}else{
		LP = (int)(L/cnt1)*100;
		printf("lunch %d\n",LP);
	}

	if(cnt2==0){
		printf("dinner no guest\n");
	}else{
		DP = (int)(D/cnt2)*100;
		printf("dinner %d\n",LP);
	}

	if(cnt==0){
		printf("midnight no guest\n");
	}else{
		MP = (int)(M/cnt)*100;
		printf("midnight %d\n",MP);
	}

	return 0;
}