### constant

TNAMES = ['lunch', 'dinner', 'midnight']

### main

loop do
  n = gets.to_i
  break if n == 0

  totals = [0] * 3
  oks = [0] * 3

  n.times do
    hm, mm = gets.strip.split
    h, m0 = hm.split(':').map(&:to_i)
    m1 = mm.to_i

    tm = m1 - m0
    tm += 60 if tm < 0

    ok = (tm <= 8)
    h += 24 if h < 2
    id = nil

    case h
    when 11..14
      id = 0
    when 18..20
      id = 1
    when 21..25
      id = 2
    end

    if ! id.nil?
      totals[id] += 1
      oks[id] += 1 if ok
    end
  end

  for i in (0..2)
    out = (totals[i] > 0) ? (100 * oks[i] / totals[i]) : 'no guest'
    puts "#{TNAMES[i]} #{out}"
  end
end