I found a simpler way of doing for the not so coding inclined type like myself.
I had to create two rules.
The first rules is to activate the switches when Person A or Person B leave while Person C is Present:
if any of these happen:
Person A Leaves
Person B Leaves
while ALL of these things are true:
Person A Is Not Present
Person B Is Not Present
Person C Is Present
then do these:
turn on x
turn on y
turn on z
Second rule is toe deactivate the switches on arrival of either Person A or Person B:
if any of these happen:
Person A arrives
Person B arrives