How can I find all binary matrices $A$ such that $A^3$ is a non-negative, integer square matrix and $$diag\left(A^3\right)=b$$ for some given vector $b$? Is there a way to characterize all the solutions?