The goddess of programming is reviewing a thick logbook, a yearly record of the visitors to her holy altar of programming. The logbook also records the goddess's own visits to the altar.
The altar attracts programmers from all over the world, because every year one visitor is chosen and endowed with the gift of miraculous programming power by the goddess. The chosen programmer is picked among those who spent the longest time at the altar while the goddess was present. There have been enthusiastic visitors who spent a very long time at the altar but failed to receive the gift, because the goddess was absent during their visits.
Your task is to write a program that finds how long the programmer who will be endowed stayed at the altar while the goddess was present.
The input is a sequence of datasets. The number of datasets is less than 100. Each dataset is formatted as follows.
n
M1/D1 h1:m1 e1 p1
M2/D2 h2:m2 e2 p2
.
.
.
Mn/Dn hn:mn en pn
The first line of a dataset contains a positive even integer $n \le 1000$, the number of lines in the logbook. It is followed by $n$ lines of space-separated data, where $M_i/D_i$ gives the month and day of the visit, $h_i:m_i$ is the time of an entrance to or an exit from the altar, $e_i$ is either I for an entrance or O for an exit, and $p_i$ identifies the visitor.
Every line of the logbook uses a fixed-column format. Both the month and the day are written with two digits, so April 1 is written as 04/01, not 4/1. The time uses the 24-hour clock, with two digits for the hour, a colon, and two digits for the minute, for example 09:13 rather than 9:13. A programmer is identified by a unique three-digit ID. The goddess's entrances and exits use the same format, and her ID is 000.
All lines of the logbook are sorted in ascending order of date and time. Because the altar closes at midnight, it is emptied at 00:00. You may assume that every time in the input is between 00:01 and 23:59, inclusive.
A programmer may leave the altar immediately after entering it. In that case the entrance and exit times are equal and the length of the visit is considered 0 minutes. For such records you may assume that the entrance line appears before the corresponding exit line in the input. You may assume that at least one programmer appears in the logbook.
The end of the input is indicated by a line containing a single zero.
For each dataset, output the total blessed time of the endowed programmer. The blessed time of a programmer is the length of their stay at the altar while the goddess is present. The endowed programmer is the one whose total blessed time is the longest among all programmers. The output is expressed in minutes. Note that the goddess of programming is not a programmer.