Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/massiv-saralanganlarni-birlashtirish

Merging sorted arrays

Medium 1000 ms 64 MB 66%
Share

Two arrays sorted in increasing order are given: of $n$ and of $m$ elements. Merge them into one array in increasing order and print it.

Two sorted arrays and a third one filled by taking the smaller of them in turn

Input

The first line contains a positive integer $n$, the second — $n$ integers.
The third line contains a positive integer $m$, the fourth — $m$ integers. Both arrays are in increasing order (equal adjacent elements are possible).

Output

$n + m$ integers separated by spaces.

Note

$1 \le n, m \le 1000$
the elements are from $-10^{6}$ to $10^{6}$

Examples

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

Sign in to submit a solution

Signing up is free and takes a minute.