[Solution] Everyone Loves to Sleep Codeforces Solution
Vlad, like everyone else, loves to sleep very much.
Every day Vlad has to do things, each at a certain time. For each of these things, he has an alarm clock set, the -th of them is triggered on hours minutes every day (). Vlad uses the -hour time format, so after comes and after comes .
This time Vlad went to bed at hours minutes () and asks you to answer: how much he will be able to sleep until the next alarm clock.
occupied
If any alarm clock rings at the time when he went to bed, then he will sleep for a period of time of length .
The first line of input data contains an integer () — the number of test cases in the test.
The first line of the case contains three integers , and () — the number of alarms and the time Vlad went to bed.
The following lines contain two numbers each and () — the time of the alarm. It is acceptable that two or more alarms will trigger at the same time.
Numbers describing time do not contain leading zeros.
Output lines, each containing the answer to the corresponding test case. As an answer, output two numbers — the number of hours and minutes that Vlad will sleep, respectively. If any alarm clock rings at the time when he went to bed, the answer will be 0 0.
No comments:
Post a Comment