欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1714A.Everyone Loves to Sleep
Everyone Loves to Sleep
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.
If any alarm clock rings at the time when he went to bed, then he will sleep for a period of time of length .
Input
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
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.
Samples
3
1 6 13
8 0
3 6 0
12 30
14 45
6 0
2 23 35
20 15
10 30
1 47
0 0
10 55
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |