fun main(args:Array<String>?): Unit {
    val lunchStart = Date(11, 0)
    val lunchEnd = Date(14, 59)
    val dinnerStart = Date(18, 0)
    val dinnerEnd = Date(20, 59)
    val midnightStart = Date(21, 0)
    val midnightEnd = Date(1, 59)
    while (true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val orders = Array(n) {
            val (date, time) = readLine()!!.trim().split(' ')
            Pair(Date.parse(date), time.toInt())
        }
        println("lunch ${countOrders(orders, lunchStart, lunchEnd).takeIf { it.first != 0 }?.let { (whole, good) -> good * 100 / whole }
                ?: "no guest"}")
        println("dinner ${countOrders(orders, dinnerStart, dinnerEnd).takeIf { it.first != 0 }?.let { (whole, good) -> good * 100 / whole }
                ?: "no guest"}")
        println("midnight ${countOrders(orders, midnightStart, midnightEnd).takeIf { it.first != 0 }?.let { (whole, good) -> good * 100 / whole }
                ?: "no guest"}")
    }
}
fun countOrders(orders: Array<Pair<Date, Int>>, from: Date, to: Date): Pair<Int, Int> {
    return orders.filter{(orderTime, _ ) ->
        orderTime.minutesFrom(from) <= to.minutesFrom(from)
    }.let{list ->
        Pair(list.size, list.count{ (orderTime, time) -> orderTime.nextTime(time).minutesFrom(orderTime) <= 8})
    }
}

data class Date(val hour: Int, val minute: Int) {
    fun minutesFrom(start: Date): Int = ((hour - start.hour) * 60 + (minute - start.minute)).let{if (it > 0) it else 60 * 24 + it}
    fun nextTime(diff: Int): Date = if (minute < diff) Date(hour, diff) else Date(hour + 1, diff)
    companion object {
        fun parse(expression: String): Date {
            val (hour, minute) = expression.split(':').map(String::toInt)
            return Date(hour, minute)
        }
    }
}
