欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1305A.Kuroni and the Gifts
Kuroni and the Gifts
Kuroni has daughters. As gifts for them, he bought necklaces and bracelets:
- the -th necklace has a brightness , where all the are pairwise distinct (i.e. all are different),
- the -th bracelet has a brightness , where all the are pairwise distinct (i.e. all are different).
Kuroni wants to give exactly one necklace and exactly one bracelet to each of his daughters. To make sure that all of them look unique, the total brightnesses of the gifts given to each daughter should be pairwise distinct. Formally, if the -th daughter receives a necklace with brightness and a bracelet with brightness , then the sums should be pairwise distinct. Help Kuroni to distribute the gifts.
For example, if the brightnesses are and , then we may distribute the gifts as follows:
- Give the third necklace and the first bracelet to the first daughter, for a total brightness of .
- Give the first necklace and the third bracelet to the second daughter, for a total brightness of .
- Give the second necklace and the second bracelet to the third daughter, for a total brightness of .
Here is an example of an invalid distribution:
- Give the first necklace and the first bracelet to the first daughter, for a total brightness of .
- Give the second necklace and the second bracelet to the second daughter, for a total brightness of .
- Give the third necklace and the third bracelet to the third daughter, for a total brightness of .
This distribution is invalid, as the total brightnesses of the gifts received by the first and the third daughter are the same. Don't make them this upset!
Input
The input consists of multiple test cases. The first line contains an integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer () — the number of daughters, necklaces and bracelets.
The second line of each test case contains distinct integers () — the brightnesses of the necklaces.
The third line of each test case contains distinct integers () — the brightnesses of the bracelets.
Output
For each test case, print a line containing integers , representing that the -th daughter receives a necklace with brightness . In the next line print integers , representing that the -th daughter receives a bracelet with brightness .
The sums should all be distinct. The numbers should be equal to the numbers in some order, and the numbers should be equal to the numbers in some order.
It can be shown that an answer always exists. If there are multiple possible answers, you may print any of them.
Note
In the first test case, it is enough to give the -th necklace and the -th bracelet to the -th daughter. The corresponding sums are , , and .
The second test case is described in the statement.
Samples
2
3
1 8 5
8 4 5
3
1 7 5
6 1 2
1 8 5
8 4 5
5 1 7
6 2 1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |