You have to set up two automations. A mirrors B and B mirrors A. Then whichever one you turn on or off, the other one matches it.
See the FAQ