#C13575. Merge and Filter Lists
Merge and Filter Lists
Merge and Filter Lists
You are given two lists of integers. Your task is to merge these two lists, remove any duplicate integers, and then output the resulting list in ascending order.
The input will be given via standard input (stdin) in the following format:
- An integer n representing the number of elements in the first list.
- A line with n space-separated integers. If n is 0, the line will contain a single space.
- An integer m representing the number of elements in the second list.
- A line with m space-separated integers. If m is 0, the line will contain a single space.
Your program should merge the two lists together, remove any duplicates, sort the resulting list in ascending order, and print the sorted integers to standard output (stdout) as space-separated values. If the resulting list is empty, print nothing.
In mathematical notation, if the two lists are given as \(L_1\) and \(L_2\), you should compute:
[ L = \text{sorted}({x: x \in L_1 \cup L_2}) ]
inputFormat
The input consists of four lines:
- An integer n on the first line, denoting the number of integers in the first list.
- The second line contains n space-separated integers. If n is 0, the line will contain a single space.
- An integer m on the third line, denoting the number of integers in the second list.
- The fourth line contains m space-separated integers. If m is 0, the line will contain a single space.
outputFormat
Output the merged list, sorted in ascending order, as a single line of space-separated integers. If the resulting list is empty, output nothing.
## sample3
1 3 5
3
2 4 6
1 2 3 4 5 6