#K77427. Merge and Sort Two Lists

    ID: 34862 Type: Default 1000ms 256MiB

Merge and Sort Two Lists

Merge and Sort Two Lists

You are given two lists of integers. Your task is to merge these two lists and output a single list containing all the integers from both lists, sorted in non-decreasing order.

The two lists will be provided in the input. Please note that the input will first give the sizes of the two lists followed by the elements for each list.

The required output is the merged and sorted list of integers, with each integer separated by a single space.

You can assume that all integers are within valid range and the input format is strictly followed.

Mathematically, if we denote the two lists as \(L_1\) and \(L_2\), then the result is \(\text{sorted}(L_1 \cup L_2)\), where \(\cup\) denotes concatenation.

inputFormat

The first line contains two integers \(n\) and \(m\), representing the sizes of the first and second list respectively.

The second line contains \(n\) space-separated integers which are the elements of the first list. If \(n = 0\), this line will be empty.

The third line contains \(m\) space-separated integers which are the elements of the second list. If \(m = 0\), this line will be empty.

It is guaranteed that \(0 \leq n, m \leq 10^5\).

outputFormat

Output a single line containing all the integers from both lists in non-decreasing order, separated by a single space.

## sample
4 5
1 3 5 7
2 4 6 8 9
1 2 3 4 5 6 7 8 9