Just verify the different possible cases

If or is , then their intersection is the and is in B.

If or is , then their intersection is the other set and is in .

If and , then if , and else.

An induction is enough to generalize that result for your second question.