def change_gates(gates, qubits):
    """
    Modifies the gates outputted from decompose_state so that they
    apply to the qubits in the list qubits
    Specifically, a gate applied to (i, j) will now apply to
    (qubits[i], qubits[j]
    """
    return [(gate, qubits[i], qubits[j]) if j is not None else
            (gate, qubits[i], None) for (gate, i, j) in gates]