Consider density matrix a[1] ^ b[1]. Contracting this will give
$$ A = \begin{bmatrix} 1 \ 2 \end{bmatrix}
\begin{bmatrix} 3 & 4 \end{bmatrix} =
\begin{bmatrix} 3 & 4 \ 6 & 8 \end{bmatrix} $$
Setting the row’s index to 1 is equivalent to picking the first element in