#C13653. Merge Two Sorted Lists

    ID: 43215 Type: Default 1000ms 256MiB

Merge Two Sorted Lists

Merge Two Sorted Lists

You are given two sorted lists (arrays) of integers. Your task is to merge these two lists into one sorted list. The merging process should preserve the sorted order. (\textbf{Note: }) The input will be provided via standard input and output should be printed to standard output. Ensure that your solution reads input from stdin and writes the merged sorted list (space-separated) to stdout.

inputFormat

The input consists of four lines:\n1. An integer (n) representing the number of elements in the first sorted list.\n2. (n) space-separated integers representing the first sorted list. (If (n = 0), this line will be empty.)\n3. An integer (m) representing the number of elements in the second sorted list.\n4. (m) space-separated integers representing the second sorted list.

outputFormat

Output a single line containing the merged sorted list. The numbers should be space-separated without any extra spaces at the end.## sample

4
1 3 5 7
4
2 4 6 8
1 2 3 4 5 6 7 8