欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1808A.Lucky Numbers
Lucky Numbers
Olympus City recently launched the production of personal starships. Now everyone on Mars can buy one and fly to other planets inexpensively.
Each starship has a number —some positive integer . Let's define the luckiness of a number as the difference between the largest and smallest digits of that number. For example, has as its largest digit and as its smallest digit, so its luckiness is . And the number has all digits equal to , so its luckiness is zero.
Hateehc is a famous Martian blogger who often flies to different corners of the solar system. To release interesting videos even faster, he decided to buy himself a starship. When he came to the store, he saw starships with numbers from to inclusively. While in the store, Hateehc wanted to find a starship with the luckiest number.
Since there are a lot of starships in the store, and Hateehc can't program, you have to help the blogger and write a program that answers his question.

Input
The first line contains an integer () —the number of test cases.
Each of the following lines contains a description of the test case. The description consists of two integers and () — the largest and smallest numbers of the starships in the store.
Output
Print lines, one line for each test case, containing the luckiest starship number in the store.
If there are several ways to choose the luckiest number, output any of them.
Note
Let's look at two test examples:
- the luckiness of the number is ;
- the luckiness of equals ;
- the luckiness of equals ;
- the luckiness of equals ;
- the luckiness of is .
Thus, the luckiest number is .
In the fifth test example, the luckiest number is .
Samples
5
59 63
42 49
15 15
53 57
1 100
60
49
15
57
90
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |