#C8599. Intersection of Two Arrays

    ID: 52598 Type: Default 1000ms 256MiB

Intersection of Two Arrays

Intersection of Two Arrays

Given two arrays of integers, your task is to compute their intersection. The intersection should include each common element only once and must be sorted in ascending order. Formally, given two sets \(A\) and \(B\), you are to output the sorted set \(A \cap B\).

The input is read as two lines from standard input where each line contains a sequence of integers separated by spaces. A blank line represents an empty array.

inputFormat

The input consists of two lines. The first line contains the first list of integers separated by spaces, and the second line contains the second list. If a line is blank, it should be interpreted as an empty array.

outputFormat

Print the intersection of the two arrays as a sequence of integers separated by a single space in ascending order. If there are no common elements, print nothing.## sample

4 9 5 4
9 4 9 8 4
4 9