#K88697. Intersection of Two Lists
Intersection of Two Lists
Intersection of Two Lists
You are given two lists of integers. Your task is to find the unique numbers that appear in both lists and output them in sorted (in ascending order) format.
Formally, given two sequences of integers \( A = [a_1, a_2, \dots, a_n] \) and \( B = [b_1, b_2, \dots, b_m] \), compute the set \( A \cap B \), then output its elements in increasing order.
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains an integer \( n \), the number of elements in the first list.
- The second line contains \( n \) space-separated integers representing the first list.
- The third line contains an integer \( m \), the number of elements in the second list.
- The fourth line contains \( m \) space-separated integers representing the second list.
You may assume that \( 0 \leq n, m \leq 10^5 \) and the absolute value of each integer does not exceed \( 10^9 \).
outputFormat
Output a single line containing the unique integers that appear in both lists, sorted in ascending order. The numbers should be separated by a single space. If there are no common elements, output an empty line.
## sample4
1 2 2 1
2
2 2
2