#K88027. Common Elements in Two Arrays

    ID: 37217 Type: Default 1000ms 256MiB

Common Elements in Two Arrays

Common Elements in Two Arrays

You are given two arrays of integers. Your task is to find the common elements between these two arrays, remove duplicates, and output them in sorted order. In other words, if the two arrays are \(A\) and \(B\), you need to compute the sorted list of elements in \(A \cap B\).

The input is read from standard input and the result should be printed to standard output. If there are no common elements, output an empty line.

Example:

Input:
5
1 3 4 6 7
4
3 5 6 9

Output: 3 6

</p>

inputFormat

The input consists of four lines:

  1. An integer \(n\) representing the number of elements in the first array.
  2. \(n\) space-separated integers representing the first array. If \(n=0\), this line will be empty.
  3. An integer \(m\) representing the number of elements in the second array.
  4. \(m\) space-separated integers representing the second array. If \(m=0\), this line will be empty.

outputFormat

Print the common elements (without duplicates) in sorted order on a single line, separated by a single space. If there are no common elements, print an empty line.

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