#Lutece2807. 归并排序

归并排序

Migrated from Lutece 2807 归并排序

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Niuma\texttt{Niuma} 近来学习了归并排序,但是他并不满足于此。我们知道完成归并排序的两个序列必须是有序的,但是 Niuma\texttt{Niuma} 不这么认为,他想对两个不仅无序,而且长度任意的序列aia_ibib_i进行归并,同时他希望结果的字典序最小,现在请你帮助 Niuma\texttt{Niuma} 实现这个愿望。

Input

第一行一个整数nn 第二行nn个正整数,表示aia_i 第三行一个整数mm 第四行mm个正整数,表示bib_i

Output

一行n+mn+m个数,表示字典序最小的归并结果

Samples

4
1 2 3 4
5
1 2 2 3 5
1 1 2 2 2 3 3 4 5
4
1 2 2 3
4
1 2 2 1
1 1 2 2 1 2 2 3

Constraints

1n,m2×1051\le n,m\le 2 \times 10^5, 1ai,bi1031\le a_i,b_i\le 10^3

Resources

2022 UESTC ICPC Training for String and Search Algorithm