Welcome to ZOJ
Information
Problems
Runs
Statistics
Ranklist
Clarification
119 - ZOJ Monthly, August 2012 - E
Education Manage System

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Zhejiang University has an excellent education management system. From two months before the beginning of the next semester to the second week of the new semester, we have at least five rounds to choose the courses that we are going to take it.
Within a day, although there can be at most 13 classes every day, we cannot fill out all days because of a constraint on the total credits of a semester. For each course, the credits of it may be an integer or have .5 after the decimal point.
There are five classes in the morning from 8:00 a.m. to 12:15 a.m. and five classes in the afternoon from 1:15 p.m. to 5:30 p.m. In the evening, we often have some classes about art, psychology. There will be three classes, from 6:30 p.m. to 9:05 p.m.
Between classes, there is a time of five minutes or fifteen minutes to rest. Of course, the courses we have chosen cannot have the same classes at the same time.

However, due to some modification of the courses, this system is not suitable for the next semester.
Our colleges give out some special new courses, they don't follow the original time of the course, they may be started at every minute in a day of the year 2012, too late or too early is equally possible. This time our education manager encourages us to choose courses as many as possible. Now, we list all the courses during the 2012, can you tell me the most credits that we can take, please mind that continually taking classes will lead you die, so make sure to have at least five minutes' time to rest between classes.

Input

There are multiple cases. For each case, one integer n (0 <= n <= 100000) indicating the number of courses, the next n lines, one line describes one course by its beginning time, end time and credits. The time is precise in minute; it is formed by three parts: the month, the day, and the time of the day. The classes will begin at the beginning of the minute it begins, also end at the beginning of the minute it ends.

Output

For each case, output one real number with exactly one digit after the decimal point indicating the most credits you can get.

Sample Input

2
Jan 1st 1:00 a.m. Feb 2nd 2:00 p.m. 2.5
Feb 3rd 8:00 a.m. Feb 3rd 8:01 a.m. 1

Sample Output

3.5

Hint

The month is presented by its first three alphabets.
The time should be between 0:00 and 11:59.


Author: HE, Ningxu
Submit    Status