Solution (source code)

= Solution

A two-sided <matrix inverse> requires a <square matrix>, so $\boxed{n=3}$ is necessary. It exists only if that <square matrix> is also an <invertible matrix>, equivalently $\det M\ne0$; choosing the dimension alone does not ensure invertibility.