欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1879A.Rigged!
Rigged!
Monocarp organizes a weightlifting competition. There are athletes participating in the competition, the -th athlete has strength and endurance . The -st athlete is Monocarp's friend Polycarp, and Monocarp really wants Polycarp to win.
The competition will be conducted as follows. The jury will choose a positive (greater than zero) integer , which denotes the weight of the barbell that will be used in the competition. The goal for each athlete is to lift the barbell as many times as possible. The athlete who lifts the barbell the most amount of times will be declared the winner (if there are multiple such athletes — there's no winner).
If the barbell's weight is strictly greater than the strength of the -th athlete , then the -th athlete will be unable to lift the barbell even one single time. Otherwise, the -th athlete will be able to lift the barbell, and the number of times he does it will be equal to his endurance .
For example, suppose there are athletes with parameters ; ; ; . If the weight of the barbell is , then:
- the first athlete will be able to lift the barbell times;
- the second athlete will be able to lift the barbell times;
- the third athlete will be unable to lift the barbell;
- the fourth athlete will be unable to lift the barbell.
Monocarp wants to choose in such a way that Polycarp (the -st athlete) wins the competition. Help him to choose the value of , or report that it is impossible.
Input
The first line contains one integer () — the number of test cases.
The first line of each test case contains one integer () — the number of athletes. Then lines follow, the -th of them contains two integers and (; ) — the strength and the endurance of the -th athlete.
Output
For each test case, print the answer as follows:
- if the answer exists, print one integer — the value of meeting the constraints. The integer you print should satisfy . It can be shown that if the answer exists, at least one such value of exists as well. If there are multiple answers, you can print any of them;
- otherwise, print one integer .
Note
The first test case of the example is described in the statement.
Samples
3
4
7 4
9 3
4 6
2 2
2
4 6
100 100
2
1337 3
1337 3
5
-1
-1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |