#K69152. Intersection of Two Arrays

    ID: 33023 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 of two sets (A) and (B) is defined as (A \cap B = { x : x \in A \text{ and } x \in B }). Each element in the result must be unique. The result should be printed in ascending order, with each number separated by a single space. If there is no intersection, output an empty line.

Input is provided via standard input (stdin) and output should be produced via standard output (stdout).

inputFormat

The input consists of two lines. The first line contains the elements of the first array separated by spaces. The second line contains the elements of the second array separated by spaces. An empty line represents an empty array.

outputFormat

Output the unique intersection of the two arrays in ascending order. The numbers should be printed on a single line separated by a single space. If there are no common elements, print an empty line.## sample

4 9 5
9 4 9 8 4
4 9