#C8570. Merge Two Sorted Lists

    ID: 52567 Type: Default 1000ms 256MiB

Merge Two Sorted Lists

Merge Two Sorted Lists

You are given two sorted lists of integers. Your task is to merge these two lists into one sorted list. The merged list should contain all elements from both lists in non-decreasing order.

Formally, given two lists \(A\) and \(B\) sorted in ascending order, produce a list \(C\) such that:

\(C = A \cup B\) and \(C\) is sorted in ascending order.

Input will be provided via standard input and your output should be printed to standard output.

inputFormat

The input consists of 4 lines:

  1. The first line contains an integer \(n_1\), the number of elements in the first list.
  2. The second line contains \(n_1\) space-separated integers in ascending order.
  3. The third line contains an integer \(n_2\), the number of elements in the second list.
  4. The fourth line contains \(n_2\) space-separated integers in ascending order.

outputFormat

Output the merged sorted list as a sequence of space-separated integers on a single line. Ensure that the output does not contain extra spaces at the beginning or end.

## sample
3
1 3 5
3
2 4 6
1 2 3 4 5 6