All tasks
Mediumtwo-pointersarrayssorting

Merge Sorted Arrays

Time limit 2 s · Memory 64 MB

Statement

The first line contains n, the second line contains n integers in non-decreasing order; the third line contains m, the fourth line contains m integers in non-decreasing order. Print all n + m numbers in non-decreasing order on one line separated by spaces.

Constraints

1 ≤ n, m ≤ 10^5 -10^9 ≤ a_i, b_i ≤ 10^9

Examples

Input 1
3
1 4 7
3
2 5 6
Output 1
1 2 4 5 6 7
Input 2
2
1 2
2
1 2
Output 2
1 1 2 2
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.