the i-th necklace has a brightness ai, where all the ai are pairwise distinct (i.e. all ai are different),

the i-th bracelet has a brightness bi, where all the bi are pairwise distinct (i.e. all bi 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 i-th daughter receives a necklace with brightness xi and a bracelet with brightness yi, then the sums xi+yi should be pairwise distinct. Help Kuroni to distribute the gifts.

For example, if the brightnesses are a=[1,7,5] and b=[6,1,2], 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 a3+b1=11.

Give the first necklace and the third bracelet to the second daughter, for a total brightness of a1+b3=3.

Give the second necklace and the second bracelet to the third daughter, for a total brightness of a2+b2=8.

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 a1+b1=7.

Give the second necklace and the second bracelet to the second daughter, for a total brightness of a2+b2=8.

Give the third necklace and the third bracelet to the third daughter, for a total brightness of a3+b3=7.

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 t (1≤t≤100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n (1≤n≤100) — the number of daughters, necklaces and bracelets.

The second line of each test case contains n distinct integers a1,a2,…,an (1≤ai≤1000) — the brightnesses of the necklaces.

The third line of each test case contains n distinct integers b1,b2,…,bn (1≤bi≤1000) — the brightnesses of the bracelets.

Output

For each test case, print a line containing n integers x1,x2,…,xn, representing that the i-th daughter receives a necklace with brightness xi. In the next line print n integers y1,y2,…,yn, representing that the i-th daughter receives a bracelet with brightness yi.

The sums x1+y1,x2+y2,…,xn+yn should all be distinct. The numbers x1,…,xn should be equal to the numbers a1,…,an in some order, and the numbers y1,…,yn should be equal to the numbers b1,…,bn in some order.

It can be shown that an answer always exists. If there are multiple possible answers, you may print any of them.

Example

inputCopy

2

3

1 8 5

8 4 5

3

1 7 5

6 1 2

outputCopy

1 8 5

8 4 5

5 1 7

6 2 1

Note

In the first test case, it is enough to give the i-th necklace and the i-th bracelet to the i-th daughter. The corresponding sums are 1+8=9, 8+4=12, and 5+5=10.

The second test case is described in the statement.

使每个a+b不同,因为每个a不同,b同所以不会有,ai+bi=aj+bj。只有ai<aj且bi>bj或者反过来,显然

#include <bits/stdc++.h>
using namespace std;
template <typename t>
void read(t &x)
{
char ch = getchar();
x = 0;
t f = 1;
while (ch < '0' || ch > '9')
f = (ch == '-' ? -1 : f), ch = getchar();
while (ch >= '0' && ch <= '9')
x = x * 10 + ch - '0', ch = getchar();
x *= f;
} #define wi(n) printf("%d ", n)
#define wl(n) printf("%lld ", n)
#define rep(m, n, i) for (int i = m; i < n; ++i)
#define rrep(m, n, i) for (int i = m; i > n; --i)
#define P puts(" ")
typedef long long ll;
#define MOD 1000000007
#define mp(a, b) make_pair(a, b)
#define N 10005
#define fil(a, n) rep(0, n, i) read(a[i])
//---------------https://lunatic.blog.csdn.net/-------------------//
int a[N], b[N];
int main()
{
int n, t;
read(t);
while (t--)
{
read(n);
rep(0, n, i) read(a[i]);
rep(0, n, i) read(b[i]);
sort(a, a + n);
sort(b, b + n);
rep(0, n, i) wi(a[i]);
P;
rep(0, n, i) wi(b[i]);
P;
}
}

Codeforce-Ozon Tech Challenge 2020-A. Kuroni and the Gifts的更多相关文章

  1. Codeforce-Ozon Tech Challenge 2020-D. Kuroni and the Celebration(交互题+DFS)

    After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Ital ...

  2. Codeforce-Ozon Tech Challenge 2020-C. Kuroni and Impossible Calculation(鸽笼原理)

    To become the king of Codeforces, Kuroni has to solve the following problem. He is given n numbers a ...

  3. Codeforce-Ozon Tech Challenge 2020-B. Kuroni and Simple Strings(贪心)

    B. Kuroni and Simple Strings time limit per test1 second memory limit per test256 megabytes inputsta ...

  4. codeforce AIM tech Round 4 div 2 B rectangles

    2017-08-25 15:32:14 writer:pprp 题目: B. Rectangles time limit per test 1 second memory limit per test ...

  5. Codechef May Challenge 2020 Division 1 记录

    目录 Triple Sort Sorting Vases Buying a New String Chef and Bitwise Product Binary Land Not a Real Wor ...

  6. Codechef July Challenge 2020 Division 1 记录

    目录 Missing a Point Chefina and Swaps Doctor Chef Chef and Dragon Dens LCM Constraints Weird Product ...

  7. Codechef June Challenge 2020 Division 1 记录

    目录 The Tom and Jerry Game! Operations on a Tuple The Delicious Cake Convenient Airports Guessing Gam ...

  8. 论文翻译:2021_论文翻译:2018_F-T-LSTM based Complex Network for Joint Acoustic Echo Cancellation and Speech Enhancement

    论文地址:https://arxiv.53yu.com/abs/2106.07577 基于 F-T-LSTM 复杂网络的联合声学回声消除和语音增强 摘要 随着对音频通信和在线会议的需求日益增加,在包括 ...

  9. V8中的快慢属性(图文分解更易理解)

    出于好奇:js中使用json存数据查找速度快,还是使用数组存数据查找快? 探究V8中对象的实现原理,熟悉数组索引属性.命名属性.对象内属性.隐藏类.描述符数组.快慢属性等等. D8调试工具使用请来这里 ...

随机推荐

  1. Vulnhub DC-9靶机渗透

    信息搜集 nmap -sP 192.168.146.0/24 #主机发现 nmap -A 192.168.146.147 #扫描端口等信息 22端口过滤,80端口开放,同样的从80端口入手. 不是现成 ...

  2. ESLint如何配置

    1.简介 通过用 ESLint 来检查一些规则,我们可以: 统一代码风格规则,如:代码缩进用几个空格:是否用驼峰命名法来命名变量和函数名等. 减少错误, 如:相等比较必须用 === ,变量在使用前必须 ...

  3. java集合中的一个移除数据陷阱(遍历集合自身并同时删除被遍历数据)

    下面是网上的其他解释,更能从本质上解释原因:Iterator 是工作在一个独立的线程中,并且拥有一个 mutex 锁. Iterator 被创建之后会建立一个指向原来对象的单链索引表,当原来的对象数量 ...

  4. 收集免费的接口服务,做一个api的搬运工

    hello, 大家好,今天给大家推荐的开源项目在某种程度上极大的方便了广大的开发者,这个开源项目统计了网上诸多的免费API,为广大开发者收集免费的接口服务,专心致志做一个API的搬运工,每月定时更新新 ...

  5. Hadoop学习笔记(2)-HDFS的基本操作(Shell命令)

    在这里我给大家继续分享一些关于HDFS分布式文件的经验哈,其中包括一些hdfs的基本的shell命令的操作,再加上hdfs java程序设计.在前面我已经写了关于如何去搭建hadoop这样一个大数据平 ...

  6. python超实用的30 个简短的代码片段(三)

    Python是目前最流行的语言之一,它在数据科学.机器学习.web开发.脚本编写.自动化方面被许多人广泛使用. 它的简单和易用性造就了它如此流行的原因. 如果你正在阅读本文,那么你或多或少已经使用过P ...

  7. UML(续)

    活动图 活动图定义 活动图描述了在一个过程中,顺序的/并行的活动及其之间的关系 应用于商业过程.工作流(业务过程).复杂算法的建模 活动图是顶点和弧的集合 活动节点 动作 流 对象值 注解和约束等 建 ...

  8. 爬虫实战2_有道翻译sign破解

    目标url 有道翻译 打开网站输入要翻译的内容,一一查找network发现数据返回json格式,红框就是我们的翻译结果 查看headers,发现返回结果的请求是post请求,且携带一大堆form_da ...

  9. [安全] Kali Linux安装TheFatRat

    一.解决访问国外网络的问题 由于字符敏感,以下所有vray的第二位都需要加上"2". 1.使用vray客户端 前提条件:拥有一个海外vray服务器提供socks5代理. 1)下载v ...

  10. Maven+JSP+Servlet+JDBC+Redis+Mysql实现的黑马旅游网

    项目简介 项目来源于:https://gitee.com/haoshunyu/travel 本系统是基于Maven+JSP+Servlet+JdbcTemplate+Redis+Mysql实现的旅游网 ...