12. Place 2 $a$s and 2 $b$s in the 16 small squares shown in the figure, with at most one letter in each small square. If the same letters must not be in the same row or column, the number of different ways to fill the squares is $\qquad$ (answer in digits).
Since the number of ways to fill in $a$ is $C_{4}^{2} \cdot A_{4}^{2}=72$ (after selecting two columns, the rows become ordered), similarly, the number of ways to fill in $b$ is also 72, at this point including the scenario where $a$ and $b$ are filled in the same cell. Thus, the number of ways to fill in $a$ and $b$ is $72^{2}$. After filling in the 2 $a$s, if both cells filled with $a$ are also filled with $b$, the number of ways to fill in is $72 \cdot 1$; if only one of the cells filled with $a$ is filled with $b$, after crossing out the row and column of this cell, there are 9 cells left, and after removing the cell of the other $a$, the number of ways to fill in the other $b$ is 8. Thus, the number of ways to fill in is $72 \cdot C_{2}^{1} \cdot 8$. (Alternatively, considering the 16 cells where both $a$ and $b$ are filled, and the 9 remaining cells to fill in the other $a$ and $b$, the number of ways to fill in is $A_{9}^{2}$, so the number of ways to fill in is $16 \cdot A_{9}^{2}$.)

Therefore, the number of different ways to fill in that satisfy the problem is $72^{2}-72-16 \cdot 72=72 \cdot 55=3960$.