Intersection of unique elements considering multiplicity

Python Hard sets

Task «Intersection of unique elements considering multiplicity»

Given two lists of integers. Find the intersection of their unique elements, considering that each element can appear at most once, even if it repeats in the original lists. However, if an element is present in both lists, but appears multiple times in one of them, it is included in the intersection with the minimum multiplicity of the two. If an element appears in one list but not in the other, it is not included in the intersection. Output the elements of the intersection sorted in ascending order, each on a new line. If the intersection is empty, output 'empty'.

Input Format

Two strings. The first string contains integers of the first list, separated by spaces. The second string contains integers of the second list, separated by spaces.

Output Format

Sorted integers in ascending order, each on a new line. If the intersection is empty, output 'empty'.

Examples

Example 1

INPUT
5 5 5 1 2 3
OUTPUT
empty
main.py