#C13197. Intersection of Two Lists

    ID: 42708 Type: Default 1000ms 256MiB

Intersection of Two Lists

Intersection of Two Lists

Given two lists of integers, compute their intersection. The intersection should contain unique elements and be sorted in ascending order. In other words, if we denote the two sets as \(A\) and \(B\), then your task is to compute \(A \cap B\) and print the elements in increasing order.

The input is provided via standard input and the output must be printed to standard output.

inputFormat

The input consists of four lines:

  • The first line contains an integer \(n\), the number of elements in the first list.
  • The second line contains \(n\) space-separated integers.
  • The third line contains an integer \(m\), the number of elements in the second list.
  • The fourth line contains \(m\) space-separated integers.

outputFormat

Print the unique elements that appear in both lists in ascending order, separated by a single space. If there are no common elements, print an empty line.

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

</p>