Question: working with subsets

Hello,

Is there any way to make this kind of problem in Maple?

I have to find the intersection of subsets, and if there is no intersection then to multiply elements of the subsets. For example,

A={x6,x4,x2,x7,x8,x9,x10},  B={x2,x3,x5,x8} and C={x4,x9,x11,x12,x13}.

Now, the intersection of A and B is {x2}, after that, I don't have the intersection with C, so the solution is x2x4, x2x9, x2x11, x2x11 and x2x13.

Another solution is to make the intersection of A and C and it will be {x4,x9} and after that, I don't have the intersection with B so I have to multiply x4 and x9 with elements in B (obviously, the first solution is better because it has fewer terms)

Is something like this is possible to do in Maple and how?

Thanks in advance! 

Please Wait...