Compute the parity into the second wire, phase that wire with the T gate, then uncompute with the same controlled-NOT gate. The answer is
For computational bits , the successive states are . The parity is one precisely on the two odd-parity inputs. Thus, in the ordered computational basis , the matrix is exactly , with no omitted overall phase. This is a two-qubit parity phase gate.
A two-qubit parity phase gate multiplies odd-parity computational vectors by and fixes even-parity ones. With ,
The first controlled-NOT gate computes in the second wire, the phase gate multiplies by , and the last controlled-NOT gate restores the original bits. This compute-phase-uncompute construction leaves the data unchanged except for the desired phases. The more general Pauli-string phase by parity computation uses the same mechanism. In terms of the Pauli Z gate, ; the scalar factor ensures equality as a matrix, rather than only up to global phase.