#C3205. Common Elements in Two Lists

    ID: 46607 Type: Default 1000ms 256MiB

Common Elements in Two Lists

Common Elements in Two Lists

You are given two lists of integers. Your task is to find all the unique elements that appear in both lists and then print these elements in decreasing order.

Input Format: The input consists of two lines. The first line contains space-separated integers representing the first list, and the second line contains space-separated integers representing the second list.

Output Format: Output a single line with the common elements in descending order separated by a single space. If there are no common elements, output an empty line.

Note: Each list may contain duplicate elements, but each common element should appear only once in the result.

Examples:

  • Input:
    4 3 7 9
    3 9 10 11
    Output:
    9 3
  • Input:
    1 2 3
    4 5 6
    Output:
    (an empty line)
  • Input:
    5 5 10 20
    5 10 20 20
    Output:
    20 10 5

inputFormat

The input is read from stdin and consists of two lines. The first line contains space-separated integers for the first list. The second line contains space-separated integers for the second list.

outputFormat

The output is written to stdout and must consist of a single line containing the common elements in descending order separated by a space. If no common elements exist, output an empty line.

## sample
4 3 7 9
3 9 10 11
9 3