#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <math.h>
#include <map>

using namespace std;

typedef long long LL;
#define INF 0x3f3f3f3f
int n;

int d[3],d1[3];
char str[3][30]={"lunch","dinner","midnight"};


void solve() {
	int a,b,c,t;
	bool vaild = false;
	memset(d,0,sizeof(d));
	memset(d1,0,sizeof(d1));
	for (int i = 0; i < n; i++) {
		scanf("%d:%d %d",&a,&b,&c);
		if (a < 2) {
			a = a + 24;
		}
	//	b += 15;
		vaild = 0;

		if (a >= 11 && a < 15) {
			d1[0]++;
			if (c > b)
				t = c - b;
			else t = c + 60 - b;
			if (t <= 8)
				d[0]++;
			//cout<<t<<endl;
		}
		if (a >= 18 && a < 21) {
			d1[1]++;
			if (c > b)
				t = c - b;
			else t = c + 60 - b;
			if (t <= 8)
				d[1]++;

		}
		if (a >= 21 && a < 26) {
			d1[2]++;
			if (c > b)
				t = c - b;
			else t = c + 60 - b;
			if (t <= 8)
				d[2]++;
		}


	}
	for (int i = 0; i < 3; i++) {
		if (!d1[i])
		printf("%s no guest\n",str[i]);
		else printf("%s %d\n",str[i],d[i]*100/d1[i]);
	}
}

int main() {
	while (scanf("%d",&n),n) {
		solve();
	}
	return 0;
}