H  — Coming Home

Time Limit: 1 sec
Memory Limit: 32 MB

John is going back home after a party. Currently he is standing on a bus station and waiting for a bus to arrive. There is a timetable of arriving buses near the station. Beside this, John also knows the amount of time that is needed to travel with specific bus. As he has only one ticket, there are no possibilities to change the bus somewhere in the middle of a trip in order to make it shorter. Can you help John to calculate minimal time that he needs to get home?

INPUT

There is a number of tests T (T ≤ 100) on the first line. Each test case contains the number of buses K (1 ≤ K ≤ 100) and current time (in format HH:MM). Each of the next K lines contain arrival time of the bus (in the same format as current time) and travelling time 0 ≤ Q ≤ 1000 needed for John to get home (in minutes). Refer to the sample input as an example.

OUTPUT

For each test case output a single line "Case T: N". Where T is the test case number (starting from 1) and N minimal time (in minutes) needed for John to go back home.

SAMPLE INPUT

2
1 18:00
19:30 30
2 18:00
19:00 100
20:00 30

SAMPLE OUTPUT

Case 1: 120
Case 2: 150

Problem by: Aleksej Viktorchik; Leonid Sislo
Huge Easy Contest #2