Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/ikki-korsatkich-massivlarni-birlashtirish

Two sorted arrays

Easy 1000 ms 128 MB 20%
Share

Two integer arrays sorted in non-decreasing order are given: $a$ with $n$ elements and $b$ with $m$ elements. Merge all their $n + m$ elements into one sequence in non-decreasing order.

Merging two sorted arrays into one sorted array

Input

The first line contains a positive integer $n$, the second line contains the $n$ integers of array $a$. The third line contains a positive integer $m$, the fourth line contains the $m$ integers of array $b$.

Output

One line with $n + m$ integers separated by spaces — the merged sorted array.

Note

$1 \le n, m \le 10^{5}$
$-10^{9} \le a_{i}, b_{j} \le 10^{9}$

Examples

Input #1
3
1 4 9
4
2 3 4 10
Output #1
1 2 3 4 4 9 10
Input #2
1
5
2
-1 5
Output #2
-1 5 5

Sign in to submit a solution

Signing up is free and takes a minute.