#C13917. Intersection of Two Arrays

    ID: 43508 Type: Default 1000ms 256MiB

Intersection of Two Arrays

Intersection of Two Arrays

Given two arrays of integers, your task is to find the intersection of these arrays. The intersection should include only unique elements that are present in both arrays. The resulting array must be sorted in ascending order.

Note: All input will be provided via standard input (stdin) and your program must output the result to standard output (stdout).

inputFormat

The input consists of four lines:

  • The first line contains an integer n representing the number of elements in the first array.
  • The second line contains n space-separated integers representing the first array.
  • The third line contains an integer m representing the number of elements in the second array.
  • The fourth line contains m space-separated integers representing the second array.

outputFormat

Output the sorted intersection array (in ascending order) with elements separated by a single space. If there is no intersection, output an empty line.

## sample
5
1 2 2 3 4
4
2 2 3 5
2 3