#C1093. Common Elements Finder

    ID: 40189 Type: Default 1000ms 256MiB

Common Elements Finder

Common Elements Finder

You are given two lists of integers. Your task is to find the common elements between these two lists, remove any duplicates, and output them in sorted order. If there is no common element, output an empty line.

Formally, if the two lists are \(L_1\) and \(L_2\), you need to compute the set: \[ S = \{ x \mid x \in L_1 \text{ and } x \in L_2 \} \] and then output the sorted sequence of the elements in \(S\).

The input is provided via standard input (stdin) and the output should be written to standard output (stdout).

inputFormat

The input consists of two lines:

  • The first line contains the elements of the first list separated by spaces. If the list is empty, the line will be empty.
  • The second line contains the elements of the second list separated by spaces. If the list is empty, the line will be empty.

You should read input from stdin.

outputFormat

Output the common elements (if any) in sorted order separated by a single space. If there are no common elements, output an empty line. The output should be written to stdout.

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