Four Set Operations
Compute four operations on the sets of values in two arrays.
Input
The first line contains n and m. The next two lines contain arrays A and B.
Array and query counts are between $1$ and $10^5$. Integer values are between $-10^9$ and $10^9$. Deleting a missing multiset value has no effect.
Output
Print four labeled lines in this order: Union:, Intersection:, Difference (A - B):, and Symmetric Difference:. Values after each label are distinct and increasing; a label has no following values when its set is empty.
Example
Input
3 4
5 10 15
10 15 20 25
Output
Union: 5 10 15 20 25
Intersection: 10 15
Difference (A - B): 5
Symmetric Difference: 5 20 25
Comments