#C12052. Intersection of Two Lists

    ID: 41437 Type: Default 1000ms 256MiB

Intersection of Two Lists

Intersection of Two Lists

Given two lists of integers, compute a list containing the unique intersection elements that appear in both lists.

The output must be displayed in ascending order, with each element separated by a single space. If there are no common elements then output an empty line.

Note: The input is provided via standard input, where the first line represents the first list (space-separated integers) and the second line represents the second list (space-separated integers). An empty line represents an empty list.

For example, if the input is:

1 2 3 4
3 4 5 6

Then the output should be:

3 4

Make sure that your solution reads from stdin and writes to stdout.

inputFormat

The input consists of exactly two lines:

  • The first line contains a series of space-separated integers representing the first list. It may be empty.
  • The second line contains a series of space-separated integers representing the second list. It may also be empty.

Input is read from standard input (stdin).

outputFormat

Output a single line to standard output (stdout) containing the unique integers that are present in both lists, sorted in ascending order and separated by a single space. If there are no common elements, output an empty line.

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