Preparation of tensor-product representation of qubits