How to build a new cmapaing member list?

How to build a new cmapaing member list?

I have number of campaigns and contacts attached to them. Suppose I have 4 campaigns: A, B, C, and D. And I have a contact X who is attached to A and D.

I'd like to get a listing all contacts who are attached to A or B and at the same same time are not attached to C or D. I thought I could make it by this:

( (X attached to A) OR (X attached to B) ) AND (X is not attached to C) AND (X not attached to D).

But this construction is still returning X which is wrong because X is attached of D.

How do I make it properly?