#K56752. Merge Two Sorted Lists

    ID: 30268 Type: Default 1000ms 256MiB

Merge Two Sorted Lists

Merge Two Sorted Lists

You are given two sorted lists of integers. The task is to merge these two lists into one sorted list. The merged list should maintain the sorted order.

Input Format: The first line contains two integers \( n \) and \( m \), representing the number of elements in the first and second lists respectively. The second line contains \( n \) integers (if \( n>0 \)) and the third line contains \( m \) integers (if \( m>0 \)).

Output Format: Output the merged sorted list as space-separated integers on a single line. If the merged list is empty, output an empty line.

Note: Make sure your solution reads from standard input (stdin) and writes to standard output (stdout).

inputFormat

The first line contains two integers n and m separated by space. The second line contains n integers (if n > 0) and the third line contains m integers (if m > 0).

outputFormat

Print the merged sorted list as space-separated integers in one line. If the list is empty, print an empty line.## sample

0 3

1 2 3
1 2 3

</p>