6. Fill two $a$s and two $b$s into a $4 \times 4$ grid, with at most one letter per cell, such that the same letters are neither in the same row nor in the same column. The number of ways to do this is $\qquad$
As shown in the figure, in a $4 \times 4$ grid, select one cell to fill in $a$, and cross out the row and column where $a$ is located. The other $a$ can only be filled in one of the 9 remaining cells, so the number of ways to place the two $a$s is $\frac{16 \times 9}{2}=72$; when the two $a$s are placed, if the two $b$s overlap with the cells of the two $a$s, there is only 1 way to place them; if one of the $b$s overlaps with one of the $a$s, the other $b$ has 8 ways to be placed, thus there are $72 \times(1+2 \times 8)$ ways that do not meet the conditions. Therefore, the number of ways that meet the conditions is $72 \times(72-17)=72 \times 55=3960$.