The product of the data Pauli Z gates has computational-basis eigenvalue
Use the parity circuit from part (ii), apply the target unitary gate , and then uncompute the parity with . For every basis input,
This equals on the data, with the ancilla qubit returned to zero. The compute-phase-uncompute construction therefore gives an exact linear-size circuit:
This is a Pauli-string phase by parity computation, an instance of simulation of a computable diagonal Hamiltonian. Part (i) also explains it by , whose exponential restricts correctly to the target- subspace. If no extra line is desired, accumulate parity into the last data qubit, apply there, and undo the CNOT gates, for gates. Both constructions implement the global phase as well as the relative phases exactly.