<s>[INST] How many different matrices $A$ and $B$ are possible such that product $AB$ is defined? Two matrices $A$ and $B$ have in total $6$ different elements (none repeated). How many different matrices $A$ and $B$ are possible such that product $AB$ is defined?
My attempts

$1^{st} Attempt$

Considering that there are $6$ different elements in both $A$ and $B$ matrices, i.e., there are total $12$ elements.


$2^{nd} Attempt$


 [/INST] This answer was revised in response to the posting of the solution.  I initially overlooked that the product of a matrix with two elements and a matrix with four elements could be formed in four ways.  The method in the posted solution is preferable to the one written below.
Your strategy is correct.  However, saying that matrices $A$ and $B$ have in total six elements means that adding the number of elements in matrix $A$ to the number of elements in matrix $B$ yields $6$.
We can partition $6$ in the following ways:
\begin{align*}
6 & = 1 + 5\\
  & = 2 + 4\\
  & = 3 + 3
\end{align*}
Thus, we can form products if we can find a matrix with one element that can be multiplied by a matrix with five elements, a matrix with two elements that can be multiplied by a matrix with four elements, or a matrix with three elements that can be multiplied by a matrix with three elements.  In each case, we can satisfy the requirement that the number of columns in $A$ is equal to the number of rows in $B$ in two ways.  
\begin{array}{c c c}
A & B & AB\\ \hline
1 \times 1 & 1 \times 5 & 1 \times 5\\
5 \times 1 & 1 \times 1 & 5 \times 1\\
1 \times 2 & 2 \times 2 & 1 \times 2\\
2 \times 2 & 2 \times 1 & 2 \times 1\\
4 \times 1 & 1 \times 2 & 4 \times 2\\
2 \times 1 & 1 \times 4 & 2 \times 4\\ 
1 \times 3 & 3 \times 1 & 1 \times 1\\
3 \times 1 & 1 \times 3 & 3 \times 3
\end{array}
Since there are $8$ possible ways to form the product and the matrices $A$ and $B$ can be populated in $6!$ different ways by $6$ distinct elements in each case, the number of different matrices $A$ and $B$ that can be constructed so that the product is defined is $8 \cdot 6!$.
</s>