欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1719B.Mathematical Circus
Mathematical Circus
A new entertainment has appeared in Buryatia — a mathematical circus! The magician shows two numbers to the audience — and , where is even. Next, he takes all the integers from to , and splits them all into pairs (each integer must be in exactly one pair) so that for each pair the integer is divisible by (note that the order of the numbers in the pair matters), or reports that, unfortunately for viewers, such a split is impossible.
Burenka really likes such performances, so she asked her friend Tonya to be a magician, and also gave him the numbers and .
Tonya is a wolf, and as you know, wolves do not perform in the circus, even in a mathematical one. Therefore, he asks you to help him. Let him know if a suitable splitting into pairs is possible, and if possible, then tell it.
Input
The first line contains one integer () — the number of test cases. The following is a description of the input data sets.
The single line of each test case contains two integers and (, , is even) — the number of integers and the number being added .
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, first output the string "YES" if there is a split into pairs, and "NO" if there is none.
If there is a split, then in the following lines output pairs of the split, in each line print numbers — first the integer , then the integer .
Note
In the first test case, splitting into pairs and is suitable, same as splitting into and .
In the second test case, is not divisible by , so there is no partition.
Samples
4
4 1
2 0
12 10
14 11
YES
1 2
3 4
NO
YES
3 4
7 8
11 12
2 1
6 5
10 9
YES
1 2
3 4
5 6
7 8
9 10
11 12
13 14
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |