Rules problem

Rules problem

Hi all,

i face an issue while writing rules for my device, i am trying to create a rule that is a 4 strings combination, means:
should contain X and should not contain Y
OR
should contain Z and should contain Y

there is a way to accomplish that?

Thanks.