#C12404. Find Common Unique Elements

    ID: 41828 Type: Default 1000ms 256MiB

Find Common Unique Elements

Find Common Unique Elements

You are given two integer arrays. Your task is to find the unique elements that are present in both arrays, and then output them in sorted order.

The input begins with two numbers which indicate the sizes of the two arrays, respectively, followed by the array elements. You need to compute the intersection of the two arrays, remove duplicates, sort the result, and print the sorted numbers separated by a space. If there are no common elements, print nothing (an empty output).

More formally, if the first array is \(A\) with \(n\) integers and the second array is \(B\) with \(m\) integers, you are required to output \(\text{sorted}(A \cap B)\).

inputFormat

The input is given through standard input (stdin) and has the following format:

n
a1 a2 ... an
m
b1 b2 ... bm

Here, n and m are non-negative integers representing the number of elements in the first and second arrays respectively. The following line contains n integers separated by spaces, and then a line with m integers separated by spaces.

outputFormat

Output the sorted common unique elements separated by a single space on one line through standard output (stdout). If there is no common element, output an empty line.

## sample
4
1 2 2 1
2
2 2
2