how to work out a quantum circuit?