TTTABLE  Train TimeTable
A train line has two stations on it, A and B. Trains can take trips from A to B or from B to A multiple times during a day. When a train arrives at B from A (or arrives at A from B), it needs a certain amount of time before it is ready to take the return journey  this is the turnaround time. For example, if a train arrives at 12:00 and the turnaround time is 0 minutes, it can leave immediately, at 12:00.
A train timetable specifies departure and arrival time of all trips between A and B. The train company needs to know how many trains have to start the day at A and B in order to make the timetable work: whenever a train is supposed to leave A or B, there must actually be one there ready to go. There are passing sections on the track, so trains don't necessarily arrive in the same order that they leave. Trains may not travel on trips that do not appear on the schedule.
Input
The first line of input gives the number of cases, N(1<=N<=100). N test cases follow.
Each case contains a number of lines. The first line is the turnaround time, T(0<=T<=60), in minutes. The next line has two numbers on it, NA and NB. NA is the number of trips from A to B, and NB is the number of trips from B to A(0<=NA,NB<=100). Then there are NA lines giving the details of the trips from A to B.
Each line contains two fields, giving the HH:MM departure and arrival time for that trip. The departure time for each trip will be earlier than the arrival time. All arrivals and departures occur on the same day. The trips may appear in any order  they are not necessarily sorted by time. The hour and minute values are both two digits, zeropadded, and are on a 24hour clock (00:00 through 23:59).
After these NA lines, there are NB lines giving the departure and arrival times for the trips from B to A.
Output
For each test case, output one line containing "Case #x: " followed by the number of trains that must start at A and the number of trains that must start at B.
Example
Input: 2 5 3 2 09:00 12:00 10:00 13:00 11:00 12:30 12:02 15:00 09:00 10:30 2 2 0 09:00 09:01 12:00 12:02 Output: Case #1: 2 2 Case #2: 2 0
hide comments
Insomniac:
20160228 12:32:43
some tricky test cases ???????? 

Deepak Singh Tomar:
20151212 15:43:08
Taught me a thing or two about implementation! Nice implementation problem. 

Rahul Lingala:
20141212 15:24:56
Last edit: 20150113 17:48:31 

512_I:
20110511 18:31:59
@abhijith: i got it :) Last edit: 20110511 18:36:43 

Marwan :
20110225 19:31:21
i think this means that the only available trips are those which are mentioned in the statement Last edit: 20110225 19:31:41 

Amit:
20100917 20:13:12
Last edit: 20120823 15:49:07 

abhijith reddy d:
20090507 11:55:46
sorry...its done nw ! Thanks 

Ahmed Kamel [ahm.kam_92]:
20090507 11:55:22
Watch out: the constraints is wrong..


Omar ElAzazy:
20090507 11:55:22
(0<=NA,NB<=60).

Added by:  abhijith reddy d 
Date:  20090427 
Time limit:  0.106s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  Google Codejam 2008 