Mr. Xifu and His New School

After working as a teacher for a long time, Mr. Xifu has finally decided to open a new school of his own. In his school, he wants to assure the highest comfort to the teachers. He has decided that any teacher will be able to take a class at any time he wishes and the classes of this school will not have any fixed duration other than the fact that a class can’t go on for more than 24 hours. In fact, classes can be happening even at midnight and classes may go over to the next day!


This is a companion discussion topic for the original entry at https://toph.co/p/mr-xifu-and-his-new-school
Input:
5
2
23:00 05:00
04:00 10:00
Output:
Case #1: Mr.Xifu needs 2 classroom(s)

Here the 1st class starts at 23:00 (11:00 pm) and ends on the next day (not the current day) at 5:00 (5:00 pm). And the 2nd class starts at 4:00 (4:00 am) and ends at 10:00 (10:00 am). So, why here need 2 classrooms in a day?

05:00 is 5:00am, not 5:00 pm

First day:
Room1: class 1=> 04:00 to 10:00 (finished)
Class 2=> 23:00 to continues

Second day:
Room1: class 2=> first day 23:00 to second day 05:00
Room2: class 1=> 04:00 to 10:00 (as room1 is busy till 5 am,
and second class start at 4 am)