#C13333. Common Elements
Common Elements
Common Elements
You are given two lists of integers. Your task is to find the common elements between the two lists, remove any duplicates, and output them in ascending order.
More formally, given two lists \(A\) and \(B\), you need to compute the set \(C = A \cap B\), and then output all elements of \(C\) sorted in increasing order.
For example, if \(A = [1, 3, 4, 6, 7, 9]\) and \(B = [1, 2, 4, 5, 9, 10]\), the common elements are \(1, 4, 9\).
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains a non-negative integer \(n\), representing the number of elements in the first list.
- The second line contains \(n\) integers separated by spaces, representing the first list. If \(n=0\), this line will be empty.
- The third line contains a non-negative integer \(m\), representing the number of elements in the second list.
- The fourth line contains \(m\) integers separated by spaces, representing the second list. If \(m=0\), this line will be empty.
outputFormat
Output the common elements (without duplicate values) between the two lists in ascending order, printed as a single line with each number separated by a space. If there are no common elements, output an empty line.
## sample6
1 3 4 6 7 9
6
1 2 4 5 9 10
1 4 9