Convert activation table into gates, with shared ancilla bits.