beecrowd | 1420

Counting Seconds

Maratona de Programação IME-USP Brazil
Timelimit: 1
Through research and the spectacular development of revolutionary techniques of computing, statistics and intuition, a group of women at the University of Torrinha developed a software able to predict the future. In fact, the program cannot describe exactly what will happen, but by analyzing the responses to a series of questions about the person, it can identify when the next five most important events in her life will happen. The program has two small problems. The first is that the person upon whom one wants to predict the future need to spend hundreds of hours straight in front of the computer, answering questions asked by the software, so it can make the prediction. The second is that the predictions are made in number of seconds from the end of the processing. The girls of Torrinha are engaged in solving the first problem, and they asked to the Programming Marathon competitors a help to solve the second.

Input

The input consists of several predictions related to different people. The first line of each prediction contains the exact moment that the 5 numbers (corresponding to the 5 key moments) were printed by the program. This moment follows the format:

<day of week>,<day><month><year>:<hour>:<minute>:<second>

where the <day of week> is the abbreviation of the weekday corresponding sequence composed of three uppercase characters corresponding to the days of the week from Sunday to Saturday respectively, such as: DOM, SEG, TER, QUA, QUI, SEX or SAB. <day> is the day of month, written with two digits, leading zero if necessary. <month> is the abbreviation of the corresponding month, comprising the sequence of 3 uppercase characters corresponding to the months from January to December, respectively, such as: JAN, FEV, MAR, ABR, MAI, JUN, JUL, AGO, SET, OUT, NOV or DEZ. <year> is the year, written with four digits. <hour>, <minute> and <second> written with two digits, leading zero if necessary.

The following lines contain 5 moments, one per line, 5 lines per prediction. Each moment d is the number of seconds (0 < d < 2.000.000.000) from the time of processing. After the last test case, a line beginning with 'FIM' indicates the end of the input file.

You can assume that the program developed on 01 March 2002 so that no prediction time is earlier than this. Another important fact is that the girls of Torrinha will only use the program until 23:59:59 of 31/12/2099 when one of them thinks she will die, because it was predicted by another program prepared by the department of women's intuition at Unitor (University of Torrinha).

Output

Your program should identify each prediction in the output by a serial number in the first line, and the following five lines you must write five full moments relating to the prediction made ​​in the same format used on the input to process th prediction. You should also skip a line at the end of each prediction.

Sample Input Sample Output

DOM,18AGO2002:12:00:00
1
2
60
3600
86400
QUI,28FEV2002:23:59:59
1
2
3
4
5
FIM

Previsao #1
DOM,18AGO2002:12:00:01
DOM,18AGO2002:12:00:02
DOM,18AGO2002:12:01:00
DOM,18AGO2002:13:00:00
SEG,19AGO2002:12:00:00
Previsao #2
SEX,01MAR2002:00:00:00
SEX,01MAR2002:00:00:01
SEX,01MAR2002:00:00:02
SEX,01MAR2002:00:00:03
SEX,01MAR2002:00:00:04