#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
    int n;
    while (scanf("%d", &n), n)
    {
	int t[3][2] = { 0 };
	static const int begin[] = { 11*60, 18*60, 21*60 };
	static const int end[] = { 14*60+59, 20*60+59, 25*60+59 };
	while (n--)
	{
	    int h, m, mm;
	    scanf("%d:%d %d", &h, &m, &mm);
	    if (h < 2)
		h += 24;
	    int time = h*60 + m;
	    int take = (mm+60 - m) % 60;
	    for (int i = 0; i < 3; ++i)
	    {
		if (begin[i] <= time && time <= end[i])
		{
		    ++t[i][0];
		    if (take <= 8)
			++t[i][1];
		}
	    }
	}
	const char* hoge[] = { "lunch", "dinner", "midnight" };
	for (int i = 0; i < 3; ++i)
	{
	    printf("%s ", hoge[i]);
	    if (t[i][0])
		printf("%d\n", 100 * t[i][1] / t[i][0]);
	    else
		puts("no guest");
	}
    }
}