Suppose we have $A \in M_3(\Bbb N\cup\{0\})$ s.t. sum of the elements of each row is $k $ for some fixed $k\in \Bbb N\cup\{0\}$. What are all the possibilities of $A$ s.t. $\det(A)=k$?

We can start from

- $k=0$ here we have to have the matrix to be zero.
- For $k=2$, I am getting $$ \begin{pmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 1 \\ \end{pmatrix} $$ as one such matrix then what are the other possibilities and can you give me a general question.
- Then what about $k=1,3$

And so on for any $k$ can we give a general structure?

Then this question can be extended to $A\in M_4(\Bbb N \cup{0})$.

By the way, what I want is if someone can give me some of the partial answers as the general answer might be too strong to expect!

For example first, just give me answer/idea for $k=2$ and then $k=3$ for $A \in M_3(\Bbb N\cup\{0\})$.

You can also give me reference of sage or any other tool that you are using.