Extraordinarily large LED

You’re arranging a basket ball match in your university. In order to attract more people to watch the game, you decided to use an extraordinarily large LED display for the scores. However, the huge LED will consume a lot of power, so you would like to estimate the cost by analyzing some past games in your university. Your LED display consists of 6 traditional seven-segment digits, 3 digits for each team. When a segment is on, it consumes one unit of power per second. When off, it does not consume any power at all. Scores are shown without leading zeros except that for score 0, a single digit ‘0’ is shown. Input There will be at most 100 test cases. For each case, the first line is always ‘START hh:mm:ss’ which means the game starts at hh : mm : ss. The last line is always ‘END hh:mm:ss’ which means the game ends at the beginning of hh : mm : ss. There will be at least one ‘SCORE’ information between ‘START’ and ‘END’, formatted as ‘SCORE hh:mm:ss team score’, where team is either ‘home’ or ‘guest’, score is 1, 2 or 3. The information will be sorted in increasing order of time, and no two times are equal. The game will start no earlier than 9:00 and will end no later than 21:00 in the same day. Note that if the start time is 09:00:00 and the end time is 09:00:01, the game duration is 1 second, not 2 seconds. Output For each test case, print the case number and the total power consumed. Sample Input START 09:00:00 SCORE 09:01:05 home 2 SCORE 09:10:07 guest 3 END 09:15:00 START 09:00:00 SCORE 10:00:00 home 1 SCORE 11:00:00 home 1 SCORE 12:00:00 home 1 SCORE 13:00:00 home 1 SCORE 14:00:00 home 1 SCORE 15:00:00 home 1 SCORE 16:00:00 home 1 SCORE 17:00:00 home 1 SCORE 18:00:00 home 1 SCORE 19:00:00 home 1 SCORE 20:00:00 home 1 END 21:00:00

2/2 Sample Output Case 1: 9672 Case 2: 478800